[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6EVTNX87CA50SJR0BQTF8VV":3,"skill-same:01M6EVTNX87CA50SJR0BQTF8VV":103},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":44,"linkOnly":45,"markdownContent":46,"markdownBody":47,"frontMatter":48,"refName":64,"commitSha":65,"skillDirectory":66,"forksCount":14,"repositoryHtmlUrl":67,"repositoryHomepageUrl":68,"ownerHtmlUrl":69,"ownerBlogUrl":6,"ownerDescription":70,"updatedAt":71,"install":72,"resources":85},"01M6EVTNX87CA50SJR0BQTF8VV","performing-file-carving-with-foremost",null,"Recover files from disk images and unallocated space using Foremost's header-footer signature carving to extract evidence regardless of file system state.","henriquescastilho\u002Fmy-claude","henriquescastilho","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F153296945?v=4","01M6ESH7EXPXTH9CVQ4K16SRG8","Henrique Scheer","01M6ESH7JHEK2PTNNH4HEH787Z",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fperforming-file-carving-with-foremost\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43],"with","file","foremost","performing file carving with foremost","evidence-recovery","de","files","images","evidence","system","disk","unallocated-space","cybersecurity","data-recovery","file-carving","recovery","t1059","data","forensics","state","2026-11-10 10:12:30",false,"---\nname: performing-file-carving-with-foremost\ndescription: Recover files from disk images and unallocated space using Foremost's\n  header-footer signature carving to extract evidence regardless of file system state.\ndomain: cybersecurity\nsubdomain: digital-forensics\ntags:\n- forensics\n- file-carving\n- foremost\n- data-recovery\n- evidence-recovery\n- unallocated-space\nversion: '1.0'\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- RS.AN-01\n- RS.AN-03\n- DE.AE-02\n- RS.MA-01\nmitre_attack:\n- T1005\n- T1074\n- T1119\n- T1070\n- T1059\n---\n\n# Performing File Carving with Foremost\n\n## When to Use\n- When recovering files from unallocated disk space or corrupted file systems\n- For extracting evidence from formatted or wiped storage media\n- When file system metadata is unavailable but raw data sectors contain evidence\n- During investigations requiring recovery of specific file types from raw images\n- As a complement to file system-based recovery for maximum evidence extraction\n\n## Prerequisites\n- Foremost installed on forensic workstation\n- Forensic disk image in raw (dd) format\n- Sufficient output storage (potentially larger than source)\n- Custom foremost.conf for specialized file types (optional)\n- Understanding of file signatures (magic bytes) for target file types\n- Scalpel as an alternative for performance-critical carving\n\n## Workflow\n\n### Step 1: Install and Configure Foremost\n\n```bash\n# Install Foremost\nsudo apt-get install foremost\n\n# Verify installation\nforemost -V\n\n# Review default configuration\ncat \u002Fetc\u002Fforemost.conf\n\n# The default foremost.conf supports:\n# jpg, gif, png, bmp - Image formats\n# avi, exe, mpg, wav - Media and executables\n# riff, wmv, mov, pdf - Documents and video\n# ole (doc\u002Fxls\u002Fppt), zip, rar - Office and archives\n# htm, cpp, java - Text\u002Fcode files\n\n# Create custom configuration for additional file types\ncp \u002Fetc\u002Fforemost.conf \u002Fcases\u002Fcase-2024-001\u002Fcustom_foremost.conf\n\n# Add custom file signatures\ncat \u003C\u003C 'EOF' >> \u002Fcases\u002Fcase-2024-001\u002Fcustom_foremost.conf\n# Custom additions for investigation\n# Format: extension  case_sensitive  max_size  header  footer\n    docx    y    10000000    \\x50\\x4b\\x03\\x04    \\x50\\x4b\\x05\\x06\n    xlsx    y    10000000    \\x50\\x4b\\x03\\x04    \\x50\\x4b\\x05\\x06\n    pptx    y    10000000    \\x50\\x4b\\x03\\x04    \\x50\\x4b\\x05\\x06\n    sqlite  y    50000000    \\x53\\x51\\x4c\\x69\\x74\\x65\\x20\\x66\\x6f\\x72\\x6d\\x61\\x74\n    pst     y    500000000   \\x21\\x42\\x44\\x4e\n    eml     y    1000000     \\x46\\x72\\x6f\\x6d\\x3a    \\x0d\\x0a\\x0d\\x0a\n    evtx    y    50000000    \\x45\\x6c\\x66\\x46\\x69\\x6c\\x65\nEOF\n```\n\n### Step 2: Run Foremost Against the Disk Image\n\n```bash\n# Basic carving of all supported file types\nforemost -t all \\\n   -i \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd \\\n   -o \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_all\u002F\n\n# Carve only specific file types\nforemost -t jpg,png,pdf,doc,xls,zip \\\n   -i \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd \\\n   -o \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_targeted\u002F\n\n# Use custom configuration\nforemost -c \u002Fcases\u002Fcase-2024-001\u002Fcustom_foremost.conf \\\n   -i \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd \\\n   -o \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_custom\u002F\n\n# Carve from a specific partition offset\n# First, find partitions\nmmls \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd\n# Then carve from unallocated space only\n# Extract unallocated space with blkls\nblkls -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd \\\n   > \u002Fcases\u002Fcase-2024-001\u002Funallocated.dd\n\nforemost -t all \\\n   -i \u002Fcases\u002Fcase-2024-001\u002Funallocated.dd \\\n   -o \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_unalloc\u002F\n\n# Verbose mode for detailed progress\nforemost -v -t all \\\n   -i \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd \\\n   -o \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_verbose\u002F 2>&1 | \\\n   tee \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_log.txt\n\n# Indirect mode (process standard input)\ndd if=\u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd bs=512 skip=2048 | \\\n   foremost -t jpg,pdf -o \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_pipe\u002F\n```\n\n### Step 3: Use Scalpel for High-Performance Carving\n\n```bash\n# Install Scalpel (faster alternative based on Foremost)\nsudo apt-get install scalpel\n\n# Edit Scalpel configuration (uncomment desired file types)\ncp \u002Fetc\u002Fscalpel\u002Fscalpel.conf \u002Fcases\u002Fcase-2024-001\u002Fscalpel.conf\n# Uncomment lines for target file types in the config\n\n# Run Scalpel\nscalpel -c \u002Fcases\u002Fcase-2024-001\u002Fscalpel.conf \\\n   -o \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fscalpel\u002F \\\n   \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd\n\n# Scalpel with file size limits\n# Edit scalpel.conf to set appropriate max sizes:\n# jpg  y  5000000  \\xff\\xd8\\xff  \\xff\\xd9\n# pdf  y  20000000 %PDF  %%EOF\n```\n\n### Step 4: Process and Validate Carved Files\n\n```bash\n# Review Foremost audit report\ncat \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_all\u002Faudit.txt\n\n# The audit.txt contains:\n# - Number of files found per type\n# - Start and end offsets\n# - File sizes\n\n# Validate carved files\npython3 \u003C\u003C 'PYEOF'\nimport os\nimport subprocess\nfrom collections import defaultdict\n\ncarved_dir = '\u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_all\u002F'\nstats = defaultdict(lambda: {'total': 0, 'valid': 0, 'invalid': 0, 'size': 0})\n\nfor subdir in os.listdir(carved_dir):\n    subdir_path = os.path.join(carved_dir, subdir)\n    if not os.path.isdir(subdir_path) or subdir == 'audit.txt':\n        continue\n\n    for filename in os.listdir(subdir_path):\n        filepath = os.path.join(subdir_path, filename)\n        if not os.path.isfile(filepath):\n            continue\n\n        ext = subdir\n        filesize = os.path.getsize(filepath)\n        stats[ext]['total'] += 1\n        stats[ext]['size'] += filesize\n\n        # Validate file using 'file' command\n        result = subprocess.run(['file', '--brief', filepath], capture_output=True, text=True)\n        file_type = result.stdout.strip()\n\n        if 'data' in file_type.lower() or 'empty' in file_type.lower():\n            stats[ext]['invalid'] += 1\n        else:\n            stats[ext]['valid'] += 1\n\nprint(\"=== CARVED FILE VALIDATION ===\\n\")\nprint(f\"{'Type':\u003C10} {'Total':\u003C8} {'Valid':\u003C8} {'Invalid':\u003C10} {'Total Size':\u003C15}\")\nprint(\"-\" * 55)\nfor ext in sorted(stats.keys()):\n    s = stats[ext]\n    size_mb = s['size'] \u002F (1024*1024)\n    print(f\"{ext:\u003C10} {s['total']:\u003C8} {s['valid']:\u003C8} {s['invalid']:\u003C10} {size_mb:>10.1f} MB\")\n\n# Remove zero-byte files\nfor subdir in os.listdir(carved_dir):\n    subdir_path = os.path.join(carved_dir, subdir)\n    if os.path.isdir(subdir_path):\n        for filename in os.listdir(subdir_path):\n            filepath = os.path.join(subdir_path, filename)\n            if os.path.isfile(filepath) and os.path.getsize(filepath) == 0:\n                os.remove(filepath)\nPYEOF\n\n# Hash all valid carved files\nfind \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_all\u002F -type f ! -name \"audit.txt\" \\\n   -exec sha256sum {} \\; > \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fcarved_file_hashes.txt\n\n# Check against known-bad hash database\n# Check against NSRL known-good database to filter\n```\n\n### Step 5: Examine and Catalog Evidence Files\n\n```bash\n# Extract metadata from carved images (EXIF data including GPS)\nexiftool -r -csv \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_all\u002Fjpg\u002F \\\n   > \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fcarved_image_metadata.csv\n\n# Search carved documents for keywords\nfind \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_all\u002Fpdf\u002F -name \"*.pdf\" -exec pdftotext {} - \\; 2>\u002Fdev\u002Fnull | \\\n   grep -iE '(confidential|secret|password|account|ssn|credit.card)' \\\n   > \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fkeyword_hits_pdf.txt\n\n# Generate thumbnails for image review\nmkdir -p \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fthumbnails\u002F\nfind \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_all\u002Fjpg\u002F -name \"*.jpg\" -exec \\\n   convert {} -thumbnail 200x200 \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fthumbnails\u002F{} \\; 2>\u002Fdev\u002Fnull\n\n# Create evidence catalog\npython3 \u003C\u003C 'PYEOF'\nimport os, hashlib, csv, subprocess\n\ncatalog = []\ncarved_dir = '\u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_all\u002F'\n\nfor subdir in sorted(os.listdir(carved_dir)):\n    subdir_path = os.path.join(carved_dir, subdir)\n    if not os.path.isdir(subdir_path):\n        continue\n    for filename in sorted(os.listdir(subdir_path)):\n        filepath = os.path.join(subdir_path, filename)\n        if not os.path.isfile(filepath):\n            continue\n        size = os.path.getsize(filepath)\n        sha256 = hashlib.sha256(open(filepath, 'rb').read()).hexdigest()\n        file_type = subprocess.run(['file', '--brief', filepath], capture_output=True, text=True).stdout.strip()\n\n        catalog.append({\n            'filename': filename,\n            'type': subdir,\n            'size': size,\n            'sha256': sha256,\n            'file_description': file_type[:100]\n        })\n\nwith open('\u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fcarved_file_catalog.csv', 'w', newline='') as f:\n    writer = csv.DictWriter(f, fieldnames=['filename', 'type', 'size', 'sha256', 'file_description'])\n    writer.writeheader()\n    writer.writerows(catalog)\n\nprint(f\"Catalog created with {len(catalog)} files\")\nPYEOF\n```\n\n## Key Concepts\n\n| Concept | Description |\n|---------|-------------|\n| File carving | Recovering files by searching for known header\u002Ffooter byte sequences in raw data |\n| File signature | Unique byte pattern at the start (header) or end (footer) identifying a file type |\n| Unallocated space | Disk sectors not assigned to any file; primary target for carving |\n| Fragmentation | When file data is stored in non-contiguous sectors, complicating carving |\n| Header-footer carving | Extracting data between known file start and end signatures |\n| False positives | Carved data matching file signatures but containing corrupt or unrelated content |\n| Slack space | Unused bytes at the end of a file's last allocated cluster |\n| Sector alignment | Files typically start at sector boundaries, improving carving accuracy |\n\n## Tools & Systems\n\n| Tool | Purpose |\n|------|---------|\n| Foremost | Original header-footer file carving tool developed for US Air Force OSI |\n| Scalpel | High-performance file carver with configurable signatures |\n| PhotoRec | Signature-based file recovery supporting 300+ formats |\n| bulk_extractor | Extracts features (emails, URLs, credit cards) from raw data |\n| blkls | Sleuth Kit tool extracting unallocated space from disk images |\n| mmls | Partition table display for identifying carving targets |\n| ExifTool | Metadata extraction from carved image and document files |\n| hashdeep | Recursive hash computation for carved file cataloging |\n\n## Common Scenarios\n\n**Scenario 1: Recovering Deleted Evidence Documents**\nRun Foremost targeting doc, pdf, xlsx formats against the unallocated space extracted with blkls, validate carved documents, search content for case-relevant keywords, catalog and hash all recoverable documents, present as evidence.\n\n**Scenario 2: Image Recovery from Formatted Media**\nCarve JPEG, PNG, GIF, BMP from a formatted USB drive image, extract EXIF metadata including GPS coordinates and camera information, generate thumbnails for rapid visual review, identify evidence-relevant images, document recovery chain.\n\n**Scenario 3: Email Recovery from Damaged PST**\nUse custom foremost.conf with PST and EML signatures, carve email artifacts from damaged Outlook data file, attempt to open carved PST fragments in a viewer, extract individual EML messages, search for relevant communications.\n\n**Scenario 4: Database Recovery for Financial Investigation**\nConfigure Foremost to carve SQLite databases from unallocated space, recover application databases that were deleted, query recovered databases for financial records, cross-reference with known transaction data, document findings for prosecution.\n\n## Output Format\n\n```\nFile Carving Summary:\n  Tool: Foremost 1.5.7\n  Source: evidence.dd (500 GB)\n  Target: Unallocated space (234 GB)\n  Duration: 1h 45m\n\n  Files Carved:\n    jpg:    2,345 files (1.8 GB) - Valid: 2,100 \u002F Invalid: 245\n    png:      234 files (456 MB) - Valid: 210 \u002F Invalid: 24\n    pdf:      156 files (890 MB) - Valid: 134 \u002F Invalid: 22\n    doc:       89 files (234 MB) - Valid: 67 \u002F Invalid: 22\n    xls:       45 files (123 MB) - Valid: 38 \u002F Invalid: 7\n    zip:       67 files (567 MB) - Valid: 52 \u002F Invalid: 15\n    exe:       34 files (234 MB) - Valid: 30 \u002F Invalid: 4\n    sqlite:    12 files (89 MB)  - Valid: 10 \u002F Invalid: 2\n\n  Total Files: 2,982 (3.4 GB recovered)\n  Evidence-Relevant: 45 files flagged for review\n  Audit Log: \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_all\u002Faudit.txt\n  File Catalog: \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fcarved_file_catalog.csv\n```\n","# Performing File Carving with Foremost\n\n## When to Use\n- When recovering files from unallocated disk space or corrupted file systems\n- For extracting evidence from formatted or wiped storage media\n- When file system metadata is unavailable but raw data sectors contain evidence\n- During investigations requiring recovery of specific file types from raw images\n- As a complement to file system-based recovery for maximum evidence extraction\n\n## Prerequisites\n- Foremost installed on forensic workstation\n- Forensic disk image in raw (dd) format\n- Sufficient output storage (potentially larger than source)\n- Custom foremost.conf for specialized file types (optional)\n- Understanding of file signatures (magic bytes) for target file types\n- Scalpel as an alternative for performance-critical carving\n\n## Workflow\n\n### Step 1: Install and Configure Foremost\n\n```bash\n# Install Foremost\nsudo apt-get install foremost\n\n# Verify installation\nforemost -V\n\n# Review default configuration\ncat \u002Fetc\u002Fforemost.conf\n\n# The default foremost.conf supports:\n# jpg, gif, png, bmp - Image formats\n# avi, exe, mpg, wav - Media and executables\n# riff, wmv, mov, pdf - Documents and video\n# ole (doc\u002Fxls\u002Fppt), zip, rar - Office and archives\n# htm, cpp, java - Text\u002Fcode files\n\n# Create custom configuration for additional file types\ncp \u002Fetc\u002Fforemost.conf \u002Fcases\u002Fcase-2024-001\u002Fcustom_foremost.conf\n\n# Add custom file signatures\ncat \u003C\u003C 'EOF' >> \u002Fcases\u002Fcase-2024-001\u002Fcustom_foremost.conf\n# Custom additions for investigation\n# Format: extension  case_sensitive  max_size  header  footer\n    docx    y    10000000    \\x50\\x4b\\x03\\x04    \\x50\\x4b\\x05\\x06\n    xlsx    y    10000000    \\x50\\x4b\\x03\\x04    \\x50\\x4b\\x05\\x06\n    pptx    y    10000000    \\x50\\x4b\\x03\\x04    \\x50\\x4b\\x05\\x06\n    sqlite  y    50000000    \\x53\\x51\\x4c\\x69\\x74\\x65\\x20\\x66\\x6f\\x72\\x6d\\x61\\x74\n    pst     y    500000000   \\x21\\x42\\x44\\x4e\n    eml     y    1000000     \\x46\\x72\\x6f\\x6d\\x3a    \\x0d\\x0a\\x0d\\x0a\n    evtx    y    50000000    \\x45\\x6c\\x66\\x46\\x69\\x6c\\x65\nEOF\n```\n\n### Step 2: Run Foremost Against the Disk Image\n\n```bash\n# Basic carving of all supported file types\nforemost -t all \\\n   -i \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd \\\n   -o \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_all\u002F\n\n# Carve only specific file types\nforemost -t jpg,png,pdf,doc,xls,zip \\\n   -i \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd \\\n   -o \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_targeted\u002F\n\n# Use custom configuration\nforemost -c \u002Fcases\u002Fcase-2024-001\u002Fcustom_foremost.conf \\\n   -i \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd \\\n   -o \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_custom\u002F\n\n# Carve from a specific partition offset\n# First, find partitions\nmmls \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd\n# Then carve from unallocated space only\n# Extract unallocated space with blkls\nblkls -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd \\\n   > \u002Fcases\u002Fcase-2024-001\u002Funallocated.dd\n\nforemost -t all \\\n   -i \u002Fcases\u002Fcase-2024-001\u002Funallocated.dd \\\n   -o \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_unalloc\u002F\n\n# Verbose mode for detailed progress\nforemost -v -t all \\\n   -i \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd \\\n   -o \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_verbose\u002F 2>&1 | \\\n   tee \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_log.txt\n\n# Indirect mode (process standard input)\ndd if=\u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd bs=512 skip=2048 | \\\n   foremost -t jpg,pdf -o \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_pipe\u002F\n```\n\n### Step 3: Use Scalpel for High-Performance Carving\n\n```bash\n# Install Scalpel (faster alternative based on Foremost)\nsudo apt-get install scalpel\n\n# Edit Scalpel configuration (uncomment desired file types)\ncp \u002Fetc\u002Fscalpel\u002Fscalpel.conf \u002Fcases\u002Fcase-2024-001\u002Fscalpel.conf\n# Uncomment lines for target file types in the config\n\n# Run Scalpel\nscalpel -c \u002Fcases\u002Fcase-2024-001\u002Fscalpel.conf \\\n   -o \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fscalpel\u002F \\\n   \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd\n\n# Scalpel with file size limits\n# Edit scalpel.conf to set appropriate max sizes:\n# jpg  y  5000000  \\xff\\xd8\\xff  \\xff\\xd9\n# pdf  y  20000000 %PDF  %%EOF\n```\n\n### Step 4: Process and Validate Carved Files\n\n```bash\n# Review Foremost audit report\ncat \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_all\u002Faudit.txt\n\n# The audit.txt contains:\n# - Number of files found per type\n# - Start and end offsets\n# - File sizes\n\n# Validate carved files\npython3 \u003C\u003C 'PYEOF'\nimport os\nimport subprocess\nfrom collections import defaultdict\n\ncarved_dir = '\u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_all\u002F'\nstats = defaultdict(lambda: {'total': 0, 'valid': 0, 'invalid': 0, 'size': 0})\n\nfor subdir in os.listdir(carved_dir):\n    subdir_path = os.path.join(carved_dir, subdir)\n    if not os.path.isdir(subdir_path) or subdir == 'audit.txt':\n        continue\n\n    for filename in os.listdir(subdir_path):\n        filepath = os.path.join(subdir_path, filename)\n        if not os.path.isfile(filepath):\n            continue\n\n        ext = subdir\n        filesize = os.path.getsize(filepath)\n        stats[ext]['total'] += 1\n        stats[ext]['size'] += filesize\n\n        # Validate file using 'file' command\n        result = subprocess.run(['file', '--brief', filepath], capture_output=True, text=True)\n        file_type = result.stdout.strip()\n\n        if 'data' in file_type.lower() or 'empty' in file_type.lower():\n            stats[ext]['invalid'] += 1\n        else:\n            stats[ext]['valid'] += 1\n\nprint(\"=== CARVED FILE VALIDATION ===\\n\")\nprint(f\"{'Type':\u003C10} {'Total':\u003C8} {'Valid':\u003C8} {'Invalid':\u003C10} {'Total Size':\u003C15}\")\nprint(\"-\" * 55)\nfor ext in sorted(stats.keys()):\n    s = stats[ext]\n    size_mb = s['size'] \u002F (1024*1024)\n    print(f\"{ext:\u003C10} {s['total']:\u003C8} {s['valid']:\u003C8} {s['invalid']:\u003C10} {size_mb:>10.1f} MB\")\n\n# Remove zero-byte files\nfor subdir in os.listdir(carved_dir):\n    subdir_path = os.path.join(carved_dir, subdir)\n    if os.path.isdir(subdir_path):\n        for filename in os.listdir(subdir_path):\n            filepath = os.path.join(subdir_path, filename)\n            if os.path.isfile(filepath) and os.path.getsize(filepath) == 0:\n                os.remove(filepath)\nPYEOF\n\n# Hash all valid carved files\nfind \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_all\u002F -type f ! -name \"audit.txt\" \\\n   -exec sha256sum {} \\; > \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fcarved_file_hashes.txt\n\n# Check against known-bad hash database\n# Check against NSRL known-good database to filter\n```\n\n### Step 5: Examine and Catalog Evidence Files\n\n```bash\n# Extract metadata from carved images (EXIF data including GPS)\nexiftool -r -csv \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_all\u002Fjpg\u002F \\\n   > \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fcarved_image_metadata.csv\n\n# Search carved documents for keywords\nfind \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_all\u002Fpdf\u002F -name \"*.pdf\" -exec pdftotext {} - \\; 2>\u002Fdev\u002Fnull | \\\n   grep -iE '(confidential|secret|password|account|ssn|credit.card)' \\\n   > \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fkeyword_hits_pdf.txt\n\n# Generate thumbnails for image review\nmkdir -p \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fthumbnails\u002F\nfind \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_all\u002Fjpg\u002F -name \"*.jpg\" -exec \\\n   convert {} -thumbnail 200x200 \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fthumbnails\u002F{} \\; 2>\u002Fdev\u002Fnull\n\n# Create evidence catalog\npython3 \u003C\u003C 'PYEOF'\nimport os, hashlib, csv, subprocess\n\ncatalog = []\ncarved_dir = '\u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_all\u002F'\n\nfor subdir in sorted(os.listdir(carved_dir)):\n    subdir_path = os.path.join(carved_dir, subdir)\n    if not os.path.isdir(subdir_path):\n        continue\n    for filename in sorted(os.listdir(subdir_path)):\n        filepath = os.path.join(subdir_path, filename)\n        if not os.path.isfile(filepath):\n            continue\n        size = os.path.getsize(filepath)\n        sha256 = hashlib.sha256(open(filepath, 'rb').read()).hexdigest()\n        file_type = subprocess.run(['file', '--brief', filepath], capture_output=True, text=True).stdout.strip()\n\n        catalog.append({\n            'filename': filename,\n            'type': subdir,\n            'size': size,\n            'sha256': sha256,\n            'file_description': file_type[:100]\n        })\n\nwith open('\u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fcarved_file_catalog.csv', 'w', newline='') as f:\n    writer = csv.DictWriter(f, fieldnames=['filename', 'type', 'size', 'sha256', 'file_description'])\n    writer.writeheader()\n    writer.writerows(catalog)\n\nprint(f\"Catalog created with {len(catalog)} files\")\nPYEOF\n```\n\n## Key Concepts\n\n| Concept | Description |\n|---------|-------------|\n| File carving | Recovering files by searching for known header\u002Ffooter byte sequences in raw data |\n| File signature | Unique byte pattern at the start (header) or end (footer) identifying a file type |\n| Unallocated space | Disk sectors not assigned to any file; primary target for carving |\n| Fragmentation | When file data is stored in non-contiguous sectors, complicating carving |\n| Header-footer carving | Extracting data between known file start and end signatures |\n| False positives | Carved data matching file signatures but containing corrupt or unrelated content |\n| Slack space | Unused bytes at the end of a file's last allocated cluster |\n| Sector alignment | Files typically start at sector boundaries, improving carving accuracy |\n\n## Tools & Systems\n\n| Tool | Purpose |\n|------|---------|\n| Foremost | Original header-footer file carving tool developed for US Air Force OSI |\n| Scalpel | High-performance file carver with configurable signatures |\n| PhotoRec | Signature-based file recovery supporting 300+ formats |\n| bulk_extractor | Extracts features (emails, URLs, credit cards) from raw data |\n| blkls | Sleuth Kit tool extracting unallocated space from disk images |\n| mmls | Partition table display for identifying carving targets |\n| ExifTool | Metadata extraction from carved image and document files |\n| hashdeep | Recursive hash computation for carved file cataloging |\n\n## Common Scenarios\n\n**Scenario 1: Recovering Deleted Evidence Documents**\nRun Foremost targeting doc, pdf, xlsx formats against the unallocated space extracted with blkls, validate carved documents, search content for case-relevant keywords, catalog and hash all recoverable documents, present as evidence.\n\n**Scenario 2: Image Recovery from Formatted Media**\nCarve JPEG, PNG, GIF, BMP from a formatted USB drive image, extract EXIF metadata including GPS coordinates and camera information, generate thumbnails for rapid visual review, identify evidence-relevant images, document recovery chain.\n\n**Scenario 3: Email Recovery from Damaged PST**\nUse custom foremost.conf with PST and EML signatures, carve email artifacts from damaged Outlook data file, attempt to open carved PST fragments in a viewer, extract individual EML messages, search for relevant communications.\n\n**Scenario 4: Database Recovery for Financial Investigation**\nConfigure Foremost to carve SQLite databases from unallocated space, recover application databases that were deleted, query recovered databases for financial records, cross-reference with known transaction data, document findings for prosecution.\n\n## Output Format\n\n```\nFile Carving Summary:\n  Tool: Foremost 1.5.7\n  Source: evidence.dd (500 GB)\n  Target: Unallocated space (234 GB)\n  Duration: 1h 45m\n\n  Files Carved:\n    jpg:    2,345 files (1.8 GB) - Valid: 2,100 \u002F Invalid: 245\n    png:      234 files (456 MB) - Valid: 210 \u002F Invalid: 24\n    pdf:      156 files (890 MB) - Valid: 134 \u002F Invalid: 22\n    doc:       89 files (234 MB) - Valid: 67 \u002F Invalid: 22\n    xls:       45 files (123 MB) - Valid: 38 \u002F Invalid: 7\n    zip:       67 files (567 MB) - Valid: 52 \u002F Invalid: 15\n    exe:       34 files (234 MB) - Valid: 30 \u002F Invalid: 4\n    sqlite:    12 files (89 MB)  - Valid: 10 \u002F Invalid: 2\n\n  Total Files: 2,982 (3.4 GB recovered)\n  Evidence-Relevant: 45 files flagged for review\n  Audit Log: \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fforemost_all\u002Faudit.txt\n  File Catalog: \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fcarved_file_catalog.csv\n```\n",{"name":5,"tags":49,"author":50,"domain":36,"license":15,"version":51,"nist_csf":52,"subdomain":57,"description":7,"mitre_attack":58},[42,38,26,37,28,35],"mahipal","1.0",[53,54,55,56],"RS.AN-01","RS.AN-03","DE.AE-02","RS.MA-01","digital-forensics",[59,60,61,62,63],"T1005","T1074","T1119","T1070","T1059","main","7925716f065257435fdb12e97f7e52842147d5ad",".claude\u002Fskills\u002Fperforming-file-carving-with-foremost","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude","https:\u002F\u002Fclaude.com\u002Fclaude-code","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho","Software · Applied AI · Quantitative Modeling · Building with Claude.","2026-06-10 12:24:46",{"source":8,"skillName":5,"commands":73,"prompt":83,"zipAvailable":84},[74,77,80],{"tool":75,"command":76},"npx","npx skills add henriquescastilho\u002Fmy-claude --skill performing-file-carving-with-foremost",{"tool":78,"command":79},"bunx","bunx skills add henriquescastilho\u002Fmy-claude --skill performing-file-carving-with-foremost",{"tool":81,"command":82},"pnpm","pnpm dlx skills add henriquescastilho\u002Fmy-claude --skill performing-file-carving-with-foremost","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fperforming-file-carving-with-foremost\u002FSKILL.md",true,[86,91,97],{"path":87,"resourceType":87,"resourceTypeDesc":88,"sizeBytes":89,"sourceHtmlUrl":90},"LICENSE","许可证",11255,"https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fperforming-file-carving-with-foremost\u002FLICENSE",{"path":92,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":95,"sourceHtmlUrl":96},"references\u002Fapi-reference.md","REFERENCE","参考文档",1537,"https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fperforming-file-carving-with-foremost\u002Freferences\u002Fapi-reference.md",{"path":98,"resourceType":99,"resourceTypeDesc":100,"sizeBytes":101,"sourceHtmlUrl":102},"scripts\u002Fagent.py","SCRIPT","脚本",6954,"https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fperforming-file-carving-with-foremost\u002Fscripts\u002Fagent.py",[104,142,151,160,182,208],{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":108,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":125,"publishedAt":44},"01M6F0B6XPQ65AX2X0DWK8KT3E","markitdown","Convert files and office documents to Markdown. Supports PDF, DOCX, PPTX, XLSX, images (with OCR), audio (with transcription), HTML, CSV, JSON, XML, ZIP, YouTube URLs, EPubs and more.","MIT","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-writer\u002Fskills\u002Fmarkitdown\u002FSKILL.md",[111,114,117,120],{"categoryNo":112,"categoryName":113,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000002","文档处理",{"categoryNo":115,"categoryName":116,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000003","演示文稿",{"categoryNo":118,"categoryName":119,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000004","电子表格",{"categoryNo":121,"categoryName":122,"taxonomyType":123,"taxonomyTypeDesc":124},"01JBSEEDCAT000000000000034","行政与办公人员","PROFESSION","适用职业",[106,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,31,30,141,24],"docx","PDF","pptx","xlsx","documents","csv","ocr","Audio","Bash","markdown","convert","read","write","edit","html","youtube",{"skillNo":143,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":108,"licenseFileUrl":6,"sourceHtmlUrl":144,"categories":145,"keywords":150,"publishedAt":44},"01M6F06SBHR9F0SDWE282Y8075","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-writer\u002Fscientific_writer\u002F.claude\u002Fskills\u002Fmarkitdown\u002FSKILL.md",[146,147,148,149],{"categoryNo":112,"categoryName":113,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":115,"categoryName":116,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":118,"categoryName":119,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":121,"categoryName":122,"taxonomyType":123,"taxonomyTypeDesc":124},[106,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,31,30,141,24],{"skillNo":152,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":108,"licenseFileUrl":6,"sourceHtmlUrl":153,"categories":154,"keywords":159,"publishedAt":44},"01M6F02D4R14EJAPBWVDF9J9VQ","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-writer\u002F.claude\u002Fskills\u002Fmarkitdown\u002FSKILL.md",[155,156,157,158],{"categoryNo":112,"categoryName":113,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":115,"categoryName":116,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":118,"categoryName":119,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":121,"categoryName":122,"taxonomyType":123,"taxonomyTypeDesc":124},[106,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,31,30,141,24],{"skillNo":161,"name":162,"nameZh":6,"description":163,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":108,"licenseFileUrl":6,"sourceHtmlUrl":164,"categories":165,"keywords":166,"publishedAt":44},"01M6F000KS6YB4MKS774G4R8ND","zarr-python","Chunked N-D arrays for cloud storage. Compressed arrays, parallel I\u002FO, S3\u002FGCS integration, NumPy\u002FDask\u002FXarray compatible, for large-scale scientific computing pipelines.","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fzarr-python\u002FSKILL.md",[],[167,168,169,170,171,172,173,174,175,176,177,178,179,180,181],"python","zarr python","storage","integration","s3","gcs","cloud","dask","parallel","pipelines","arrays","numpy","scientific computing","scale","scientific",{"skillNo":183,"name":184,"nameZh":6,"description":185,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":108,"licenseFileUrl":6,"sourceHtmlUrl":186,"categories":187,"keywords":189,"publishedAt":44},"01M6EZZJWFXM1GR78KTW6J0DN8","what-if-oracle","Run structured What-If scenario analysis with multi-branch possibility exploration. Use this skill when the user asks speculative questions like \"what if...\", \"what would happen if...\", \"what are the possibilities\", \"explore scenarios\", \"scenario analysis\", \"possibility space\", \"what could go wrong\", \"best case \u002F worst case\", \"risk analysis\", \"contingency planning\", \"strategic options\", or any question about uncertain futures. Also trigger when the user faces a fork-in-the-road decision, wants to stress-test an idea, or needs to think through consequences before committing.","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fwhat-if-oracle\u002FSKILL.md",[188],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[190,191,192,193,194,195,196,197,198,199,200,137,138,201,202,203,204,205,206,207],"oracle","what if oracle","go","run","ux","futures","analysis","explore","decision","branch","question","idea","exploration","options","stress-test","strategies","scenario","stress",{"skillNo":209,"name":210,"nameZh":6,"description":211,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":108,"licenseFileUrl":6,"sourceHtmlUrl":212,"categories":213,"keywords":224,"publishedAt":44},"01M6EZZCXAEB49RXGQCJX5E8GB","venue-templates","Access comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fvenue-templates\u002FSKILL.md",[214,217,220,221],{"categoryNo":215,"categoryName":216,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":218,"categoryName":219,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000021","资料检索与研究",{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":222,"categoryName":223,"taxonomyType":123,"taxonomyTypeDesc":124},"01JBSEEDCAT000000000000036","内容创作者",[225,226,227,228,229,230,231,232,134,233,137,138,139,234,235,236,237,238,181,239],"templates","venue templates","research","guidelines","NeurIPS","ICML","LaTeX","science","access","proposals","Academic","requirements","formatting","journal","chi"]