[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7E2ASFC293SV8BYZSZXGZYS":3,"skill-same:01M7E2ASFC293SV8BYZSZXGZYS":85},{"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":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":47,"commitSha":48,"skillDirectory":49,"forksCount":50,"repositoryHtmlUrl":51,"repositoryHomepageUrl":6,"ownerHtmlUrl":52,"ownerBlogUrl":6,"ownerDescription":53,"updatedAt":54,"install":55,"resources":68},"01M7E2ASFC293SV8BYZSZXGZYS","analyzing-slack-space-and-file-system-artifacts",null,"Examine NTFS slack space, MFT entries, the USN Change Journal, and Alternate Data Streams (ADS) to recover hidden or residual data, reconstruct deleted-file metadata, and reconstruct available file-system change activity from USN records. Use during deep forensic analysis of an NTFS image when standard file recovery is insufficient, such as hunting for data hidden in ADS.","sanjeevafk\u002Fagent-skills","sanjeevafk","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F230678117?v=4","01M7C540EFY46ETG1NNWKS5X3Q","Sanjeev","01M7C540F366J5C1D587BMKH9Q",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fanalyzing-slack-space-and-file-system-artifacts\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fanalyzing-slack-space-and-file-system-artifacts\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: analyzing-slack-space-and-file-system-artifacts\ndescription: Examine NTFS slack space, MFT entries, the USN Change Journal, and Alternate Data Streams (ADS) to recover hidden or residual data, reconstruct deleted-file metadata, and reconstruct available file-system change activity from USN records. Use during deep forensic analysis of an NTFS image when standard file recovery is insufficient, such as hunting for data hidden in ADS.\ndomain: cybersecurity\nsubdomain: digital-forensics\ntags:\n- forensics\n- slack-space\n- ntfs\n- mft\n- usn-journal\n- alternate-data-streams\n- file-system-analysis\nversion: '1.0'\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- RS.AN-03\n- DE.AE-02\n- RS.MA-01\nmitre_attack:\n- T1070.006\n- T1564.004\n- T1070.004\n- T1005\n- T1006\n---\n\n# Analyzing Slack Space and File System Artifacts\n\n## When to Use\n- When searching for hidden or residual data in file system slack space\n- For analyzing NTFS Master File Table (MFT) entries for deleted file metadata\n- When reconstructing file operations from the USN Change Journal\n- For detecting Alternate Data Streams (ADS) used to hide data or malware\n- During deep forensic analysis requiring examination beyond standard file recovery\n\n## Prerequisites\n- Forensic disk image with NTFS file system\n- The Sleuth Kit (TSK) tools: istat, icat, fls, blkls, blkstat\n- MFTECmd (Eric Zimmerman) for MFT parsing\n- MFTExplorer for interactive MFT analysis\n- Understanding of NTFS structures (MFT, $UsnJrnl, $LogFile, ADS)\n- Python with analyzeMFT or mft library for automated parsing\n\n## Workflow\n\n### Step 1: Identify and Extract NTFS File System Artifacts\n\n```bash\n# Determine partition layout\nmmls \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd\n\n# Extract key NTFS system files\n# $MFT - Master File Table\nicat -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd 0 > \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002FMFT\n\n# $UsnJrnl:$J - USN Change Journal\nicat -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd 62-128 > \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002FUsnJrnl_J\n\n# $LogFile - Transaction log\nicat -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd 2 > \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002FLogFile\n\n# Extract all slack space from the volume\nblkls -s -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd > \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002Fslack_space.raw\n\n# Get file system information\nfsstat -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd | tee \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002Ffs_info.txt\n```\n\n### Step 2: Analyze the Master File Table (MFT)\n\n```bash\n# Parse MFT with MFTECmd (Eric Zimmerman)\nMFTECmd.exe -f \"C:\\cases\\ntfs\\MFT\" --csv \"C:\\cases\\analysis\\\" --csvf mft_analysis.csv\n\n# Parse with analyzeMFT (Python)\npip install analyzeMFT\n\nanalyzeMFT.py -f \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002FMFT \\\n   -o \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fmft_analysis.csv \\\n   -c\n\n# Custom MFT analysis with Python\npython3 \u003C\u003C 'PYEOF'\nfrom mft import PyMft\nimport csv\n\nmft = PyMft(open('\u002Fcases\u002Fcase-2024-001\u002Fntfs\u002FMFT', 'rb').read())\n\ndeleted_files = []\nsuspicious_files = []\n\nfor entry in mft.entries():\n    if entry is None:\n        continue\n\n    filename = entry.get_filename()\n    if filename is None:\n        continue\n\n    is_deleted = not entry.is_active()\n    is_directory = entry.is_directory()\n    created = entry.get_created_timestamp()\n    modified = entry.get_modified_timestamp()\n    mft_modified = entry.get_mft_modified_timestamp()\n    size = entry.get_file_size()\n\n    # Flag deleted files for recovery\n    if is_deleted and not is_directory and size > 0:\n        deleted_files.append({\n            'filename': filename,\n            'size': size,\n            'created': str(created),\n            'modified': str(modified),\n            'entry_number': entry.entry_number\n        })\n\n    # Detect timestomping (MFT modified time != $SI modified time)\n    si_modified = entry.get_si_modified_timestamp()\n    fn_modified = entry.get_fn_modified_timestamp()\n    if si_modified and fn_modified:\n        if abs((si_modified - fn_modified).total_seconds()) > 86400:  # >1 day difference\n            suspicious_files.append({\n                'filename': filename,\n                'si_modified': str(si_modified),\n                'fn_modified': str(fn_modified),\n                'delta': str(si_modified - fn_modified)\n            })\n\nprint(f\"=== DELETED FILES (recoverable metadata) ===\")\nprint(f\"Total: {len(deleted_files)}\")\nfor f in deleted_files[:20]:\n    print(f\"  [{f['modified']}] {f['filename']} ({f['size']} bytes)\")\n\nprint(f\"\\n=== POTENTIAL TIMESTOMPING ===\")\nprint(f\"Total suspicious: {len(suspicious_files)}\")\nfor f in suspicious_files[:10]:\n    print(f\"  {f['filename']}: $SI={f['si_modified']}, $FN={f['fn_modified']} (delta: {f['delta']})\")\nPYEOF\n```\n\n### Step 3: Analyze Slack Space for Hidden Data\n\n```bash\n# Search slack space for strings\nstrings -a \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002Fslack_space.raw > \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fslack_strings.txt\n\n# Search for specific patterns in slack space\ngrep -iab \"password\\|secret\\|confidential\\|credit.card\\|ssn\" \\\n   \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002Fslack_space.raw > \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fslack_keywords.txt\n\n# Analyze individual file slack\npython3 \u003C\u003C 'PYEOF'\nimport struct\n\n# File slack consists of:\n# 1. RAM slack: bytes between file end and next sector boundary (filled with RAM content or zeros)\n# 2. Drive slack: remaining sectors in the cluster after the last file sector\n\n# Analyze slack for specific MFT entries\n# Using Sleuth Kit to get file slack for a specific file\nimport subprocess\n\n# Get file details\nresult = subprocess.run(\n    ['istat', '-o', '2048', '\u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd', '14523'],\n    capture_output=True, text=True\n)\nprint(result.stdout)\n\n# The output shows data runs - the last cluster may contain slack data\n# Calculate slack size: (allocated_size - file_size) bytes\nPYEOF\n\n# Search for file signatures in slack space (embedded files)\nforemost -t jpg,pdf,zip -i \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002Fslack_space.raw \\\n   -o \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fslack_carved\u002F\n\n# Use bulk_extractor to find structured data in slack\nbulk_extractor -o \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fbulk_extract\u002F \\\n   \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002Fslack_space.raw\n```\n\n### Step 4: Parse the USN Change Journal\n\n```bash\n# Parse USN Journal with MFTECmd\nMFTECmd.exe -f \"C:\\cases\\ntfs\\UsnJrnl_J\" --csv \"C:\\cases\\analysis\\\" --csvf usn_journal.csv\n\n# Python USN Journal parsing\npip install pyusn\n\npython3 \u003C\u003C 'PYEOF'\nimport struct\nimport csv\nfrom datetime import datetime, timedelta\n\ndef parse_usn_record(data, offset):\n    \"\"\"Parse a single USN_RECORD_V2.\"\"\"\n    if offset + 8 > len(data):\n        return None, offset\n\n    record_len = struct.unpack_from('\u003CI', data, offset)[0]\n    if record_len \u003C 56 or record_len > 65536 or offset + record_len > len(data):\n        return None, offset + 8\n\n    major_ver = struct.unpack_from('\u003CH', data, offset + 4)[0]\n    if major_ver != 2:\n        return None, offset + record_len\n\n    mft_ref = struct.unpack_from('\u003CQ', data, offset + 8)[0] & 0xFFFFFFFFFFFF\n    parent_ref = struct.unpack_from('\u003CQ', data, offset + 16)[0] & 0xFFFFFFFFFFFF\n    usn = struct.unpack_from('\u003CQ', data, offset + 24)[0]\n    timestamp = struct.unpack_from('\u003CQ', data, offset + 32)[0]\n    reason = struct.unpack_from('\u003CI', data, offset + 40)[0]\n    source_info = struct.unpack_from('\u003CI', data, offset + 44)[0]\n    security_id = struct.unpack_from('\u003CI', data, offset + 48)[0]\n    file_attrs = struct.unpack_from('\u003CI', data, offset + 52)[0]\n    filename_len = struct.unpack_from('\u003CH', data, offset + 56)[0]\n    filename_off = struct.unpack_from('\u003CH', data, offset + 58)[0]\n\n    name = data[offset + filename_off:offset + filename_off + filename_len].decode('utf-16-le', errors='ignore')\n\n    # Convert Windows FILETIME to datetime\n    ts = datetime(1601, 1, 1) + timedelta(microseconds=timestamp \u002F\u002F 10)\n\n    # Decode reason flags\n    reasons = []\n    reason_flags = {\n        0x01: 'DATA_OVERWRITE', 0x02: 'DATA_EXTEND', 0x04: 'DATA_TRUNCATION',\n        0x10: 'NAMED_DATA_OVERWRITE', 0x20: 'NAMED_DATA_EXTEND',\n        0x100: 'FILE_CREATE', 0x200: 'FILE_DELETE', 0x400: 'EA_CHANGE',\n        0x800: 'SECURITY_CHANGE', 0x1000: 'RENAME_OLD_NAME', 0x2000: 'RENAME_NEW_NAME',\n        0x4000: 'INDEXABLE_CHANGE', 0x8000: 'BASIC_INFO_CHANGE',\n        0x10000: 'HARD_LINK_CHANGE', 0x20000: 'COMPRESSION_CHANGE',\n        0x40000: 'ENCRYPTION_CHANGE', 0x80000: 'OBJECT_ID_CHANGE',\n        0x100000: 'REPARSE_POINT_CHANGE', 0x200000: 'STREAM_CHANGE',\n        0x80000000: 'CLOSE'\n    }\n    for flag, desc in reason_flags.items():\n        if reason & flag:\n            reasons.append(desc)\n\n    record = {\n        'timestamp': ts.strftime('%Y-%m-%d %H:%M:%S'),\n        'filename': name,\n        'mft_entry': mft_ref,\n        'parent_entry': parent_ref,\n        'reasons': '|'.join(reasons),\n        'usn': usn\n    }\n\n    return record, offset + record_len\n\n# Parse the journal\nwith open('\u002Fcases\u002Fcase-2024-001\u002Fntfs\u002FUsnJrnl_J', 'rb') as f:\n    data = f.read()\n\nrecords = []\noffset = 0\nwhile offset \u003C len(data) - 8:\n    record, offset = parse_usn_record(data, offset)\n    if record:\n        records.append(record)\n    else:\n        offset += 8  # Skip zeros\n\n# Filter for deletion events\ndeletions = [r for r in records if 'FILE_DELETE' in r['reasons']]\ncreations = [r for r in records if 'FILE_CREATE' in r['reasons']]\nrenames = [r for r in records if 'RENAME_NEW_NAME' in r['reasons']]\n\nprint(f\"Total USN records: {len(records)}\")\nprint(f\"File creations: {len(creations)}\")\nprint(f\"File deletions: {len(deletions)}\")\nprint(f\"File renames: {len(renames)}\")\n\nprint(\"\\n=== RECENT DELETIONS ===\")\nfor r in deletions[-20:]:\n    print(f\"  [{r['timestamp']}] DELETED: {r['filename']} (MFT#{r['mft_entry']})\")\n\n# Write full journal to CSV\nwith open('\u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fusn_journal.csv', 'w', newline='') as f:\n    writer = csv.DictWriter(f, fieldnames=['timestamp', 'filename', 'mft_entry', 'parent_entry', 'reasons', 'usn'])\n    writer.writeheader()\n    writer.writerows(records)\nPYEOF\n```\n\n### Step 5: Detect and Analyze Alternate Data Streams\n\n```bash\n# List all Alternate Data Streams in the image\nfind \u002Fmnt\u002Fevidence -exec getfattr -d {} \\; 2>\u002Fdev\u002Fnull | grep -i \"ads\\|zone\\|stream\"\n\n# Using Sleuth Kit to find ADS\nfls -r -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd | grep \":\" | \\\n   tee \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fads_list.txt\n\n# Extract specific ADS content\n# Format: icat image inode:ads_name\nicat -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd 14523:hidden_stream \\\n   > \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fextracted_ads.bin\n\n# Check Zone.Identifier streams (download origin tracking)\nfls -r -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd | grep \"Zone.Identifier\" | \\\n   while read line; do\n       inode=$(echo \"$line\" | awk '{print $2}' | tr -d ':')\n       echo \"=== $line ===\"\n       icat -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd \"${inode}:Zone.Identifier\" 2>\u002Fdev\u002Fnull\n       echo \"\"\n   done > \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fzone_identifiers.txt\n\n# Zone.Identifier content reveals:\n# [ZoneTransfer]\n# ZoneId=3          (3 = Internet, indicating file was downloaded)\n# ReferrerUrl=https:\u002F\u002Fmalicious-site.com\u002Fpayload.exe\n# HostUrl=https:\u002F\u002Fcdn.malicious-site.com\u002Fpayload.exe\n```\n\n## Key Concepts\n\n| Concept | Description |\n|---------|-------------|\n| File slack | Unused space between file end and cluster boundary containing residual data |\n| RAM slack | Portion of slack from file end to sector boundary (historically filled with RAM) |\n| MFT ($MFT) | Master File Table - NTFS metadata database with entries for every file |\n| USN Journal ($UsnJrnl) | Change journal recording all file\u002Fdirectory modifications on NTFS |\n| Alternate Data Streams | NTFS feature allowing multiple data streams per file (hidden storage) |\n| $STANDARD_INFORMATION | MFT attribute with timestamps modifiable by user-mode applications |\n| $FILE_NAME | MFT attribute with timestamps only modifiable by the kernel |\n| Timestomping | Anti-forensic technique modifying file timestamps to avoid detection |\n\n## Tools & Systems\n\n| Tool | Purpose |\n|------|---------|\n| MFTECmd | Eric Zimmerman MFT and USN Journal parser with CSV output |\n| MFTExplorer | Interactive GUI tool for MFT analysis |\n| analyzeMFT | Python MFT parser with CSV\u002FJSON output |\n| The Sleuth Kit | File system forensics toolkit (fls, icat, blkls, istat) |\n| bulk_extractor | Feature extraction from raw data including slack space |\n| NTFS Log Tracker | Tool for parsing $LogFile transaction records |\n| streams.exe | Sysinternals tool for listing NTFS Alternate Data Streams |\n| Plaso | Super-timeline tool parsing MFT and USN Journal |\n\n## Common Scenarios\n\n**Scenario 1: Anti-Forensics Detection via Timestomping**\nCompare $STANDARD_INFORMATION timestamps with $FILE_NAME timestamps in MFT entries, flag files where $SI timestamps predate $FN timestamps (impossible in normal operation), identify timestomped files as evidence of deliberate manipulation, correlate with other timeline evidence.\n\n**Scenario 2: Hidden Data in Alternate Data Streams**\nScan for ADS attached to files beyond the standard Zone.Identifier, extract ADS content for analysis, check for hidden executables or documents stored in ADS, correlate ADS creation with user activity timeline, document findings for evidence.\n\n**Scenario 3: Deleted File Reconstruction from MFT**\nParse MFT for inactive (deleted) entries, extract filenames, sizes, and timestamps of deleted files, recover file content using icat if data clusters are not overwritten, build list of deleted evidence files, correlate with USN Journal delete events.\n\n**Scenario 4: File Activity Reconstruction from USN Journal**\nParse the USN Change Journal for the investigation period, identify file creation, modification, rename, and deletion events, reconstruct the sequence of file operations, detect evidence of data staging (create, copy, compress, delete pattern), identify anti-forensic file wiping.\n\n## Output Format\n\n```\nFile System Artifact Analysis:\n  Volume: NTFS (Partition 2, 465 GB)\n  Cluster Size: 4096 bytes\n\n  MFT Analysis:\n    Total Entries: 456,789\n    Active Files: 234,567\n    Deleted Entries: 12,345 (8,901 with recoverable metadata)\n    Timestomped Files: 23 (SI\u002FFN mismatch detected)\n\n  USN Journal:\n    Records Parsed: 2,345,678\n    Date Range: 2024-01-01 to 2024-01-20\n    File Creations: 45,678\n    File Deletions: 23,456\n    File Renames: 12,345\n\n  Alternate Data Streams:\n    Total ADS Found: 1,234\n    Zone.Identifier: 890 (downloaded files)\n    Custom\u002FSuspicious ADS: 5 (hidden data detected)\n\n  Slack Space:\n    Total Slack: 12.3 GB\n    Keyword Hits: 45 (passwords, credit cards)\n    Carved Files: 23 from slack space\n\n  Suspicious Findings:\n    - 23 files with timestomped timestamps\n    - 5 files with hidden ADS containing data\n    - USN shows mass deletion on 2024-01-18 (anti-forensics)\n    - Slack space contains residual email fragments\n\n  Reports: \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002F\n```\n","# Analyzing Slack Space and File System Artifacts\n\n## When to Use\n- When searching for hidden or residual data in file system slack space\n- For analyzing NTFS Master File Table (MFT) entries for deleted file metadata\n- When reconstructing file operations from the USN Change Journal\n- For detecting Alternate Data Streams (ADS) used to hide data or malware\n- During deep forensic analysis requiring examination beyond standard file recovery\n\n## Prerequisites\n- Forensic disk image with NTFS file system\n- The Sleuth Kit (TSK) tools: istat, icat, fls, blkls, blkstat\n- MFTECmd (Eric Zimmerman) for MFT parsing\n- MFTExplorer for interactive MFT analysis\n- Understanding of NTFS structures (MFT, $UsnJrnl, $LogFile, ADS)\n- Python with analyzeMFT or mft library for automated parsing\n\n## Workflow\n\n### Step 1: Identify and Extract NTFS File System Artifacts\n\n```bash\n# Determine partition layout\nmmls \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd\n\n# Extract key NTFS system files\n# $MFT - Master File Table\nicat -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd 0 > \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002FMFT\n\n# $UsnJrnl:$J - USN Change Journal\nicat -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd 62-128 > \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002FUsnJrnl_J\n\n# $LogFile - Transaction log\nicat -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd 2 > \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002FLogFile\n\n# Extract all slack space from the volume\nblkls -s -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd > \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002Fslack_space.raw\n\n# Get file system information\nfsstat -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd | tee \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002Ffs_info.txt\n```\n\n### Step 2: Analyze the Master File Table (MFT)\n\n```bash\n# Parse MFT with MFTECmd (Eric Zimmerman)\nMFTECmd.exe -f \"C:\\cases\\ntfs\\MFT\" --csv \"C:\\cases\\analysis\\\" --csvf mft_analysis.csv\n\n# Parse with analyzeMFT (Python)\npip install analyzeMFT\n\nanalyzeMFT.py -f \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002FMFT \\\n   -o \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fmft_analysis.csv \\\n   -c\n\n# Custom MFT analysis with Python\npython3 \u003C\u003C 'PYEOF'\nfrom mft import PyMft\nimport csv\n\nmft = PyMft(open('\u002Fcases\u002Fcase-2024-001\u002Fntfs\u002FMFT', 'rb').read())\n\ndeleted_files = []\nsuspicious_files = []\n\nfor entry in mft.entries():\n    if entry is None:\n        continue\n\n    filename = entry.get_filename()\n    if filename is None:\n        continue\n\n    is_deleted = not entry.is_active()\n    is_directory = entry.is_directory()\n    created = entry.get_created_timestamp()\n    modified = entry.get_modified_timestamp()\n    mft_modified = entry.get_mft_modified_timestamp()\n    size = entry.get_file_size()\n\n    # Flag deleted files for recovery\n    if is_deleted and not is_directory and size > 0:\n        deleted_files.append({\n            'filename': filename,\n            'size': size,\n            'created': str(created),\n            'modified': str(modified),\n            'entry_number': entry.entry_number\n        })\n\n    # Detect timestomping (MFT modified time != $SI modified time)\n    si_modified = entry.get_si_modified_timestamp()\n    fn_modified = entry.get_fn_modified_timestamp()\n    if si_modified and fn_modified:\n        if abs((si_modified - fn_modified).total_seconds()) > 86400:  # >1 day difference\n            suspicious_files.append({\n                'filename': filename,\n                'si_modified': str(si_modified),\n                'fn_modified': str(fn_modified),\n                'delta': str(si_modified - fn_modified)\n            })\n\nprint(f\"=== DELETED FILES (recoverable metadata) ===\")\nprint(f\"Total: {len(deleted_files)}\")\nfor f in deleted_files[:20]:\n    print(f\"  [{f['modified']}] {f['filename']} ({f['size']} bytes)\")\n\nprint(f\"\\n=== POTENTIAL TIMESTOMPING ===\")\nprint(f\"Total suspicious: {len(suspicious_files)}\")\nfor f in suspicious_files[:10]:\n    print(f\"  {f['filename']}: $SI={f['si_modified']}, $FN={f['fn_modified']} (delta: {f['delta']})\")\nPYEOF\n```\n\n### Step 3: Analyze Slack Space for Hidden Data\n\n```bash\n# Search slack space for strings\nstrings -a \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002Fslack_space.raw > \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fslack_strings.txt\n\n# Search for specific patterns in slack space\ngrep -iab \"password\\|secret\\|confidential\\|credit.card\\|ssn\" \\\n   \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002Fslack_space.raw > \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fslack_keywords.txt\n\n# Analyze individual file slack\npython3 \u003C\u003C 'PYEOF'\nimport struct\n\n# File slack consists of:\n# 1. RAM slack: bytes between file end and next sector boundary (filled with RAM content or zeros)\n# 2. Drive slack: remaining sectors in the cluster after the last file sector\n\n# Analyze slack for specific MFT entries\n# Using Sleuth Kit to get file slack for a specific file\nimport subprocess\n\n# Get file details\nresult = subprocess.run(\n    ['istat', '-o', '2048', '\u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd', '14523'],\n    capture_output=True, text=True\n)\nprint(result.stdout)\n\n# The output shows data runs - the last cluster may contain slack data\n# Calculate slack size: (allocated_size - file_size) bytes\nPYEOF\n\n# Search for file signatures in slack space (embedded files)\nforemost -t jpg,pdf,zip -i \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002Fslack_space.raw \\\n   -o \u002Fcases\u002Fcase-2024-001\u002Fcarved\u002Fslack_carved\u002F\n\n# Use bulk_extractor to find structured data in slack\nbulk_extractor -o \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fbulk_extract\u002F \\\n   \u002Fcases\u002Fcase-2024-001\u002Fntfs\u002Fslack_space.raw\n```\n\n### Step 4: Parse the USN Change Journal\n\n```bash\n# Parse USN Journal with MFTECmd\nMFTECmd.exe -f \"C:\\cases\\ntfs\\UsnJrnl_J\" --csv \"C:\\cases\\analysis\\\" --csvf usn_journal.csv\n\n# Python USN Journal parsing\npip install pyusn\n\npython3 \u003C\u003C 'PYEOF'\nimport struct\nimport csv\nfrom datetime import datetime, timedelta\n\ndef parse_usn_record(data, offset):\n    \"\"\"Parse a single USN_RECORD_V2.\"\"\"\n    if offset + 8 > len(data):\n        return None, offset\n\n    record_len = struct.unpack_from('\u003CI', data, offset)[0]\n    if record_len \u003C 56 or record_len > 65536 or offset + record_len > len(data):\n        return None, offset + 8\n\n    major_ver = struct.unpack_from('\u003CH', data, offset + 4)[0]\n    if major_ver != 2:\n        return None, offset + record_len\n\n    mft_ref = struct.unpack_from('\u003CQ', data, offset + 8)[0] & 0xFFFFFFFFFFFF\n    parent_ref = struct.unpack_from('\u003CQ', data, offset + 16)[0] & 0xFFFFFFFFFFFF\n    usn = struct.unpack_from('\u003CQ', data, offset + 24)[0]\n    timestamp = struct.unpack_from('\u003CQ', data, offset + 32)[0]\n    reason = struct.unpack_from('\u003CI', data, offset + 40)[0]\n    source_info = struct.unpack_from('\u003CI', data, offset + 44)[0]\n    security_id = struct.unpack_from('\u003CI', data, offset + 48)[0]\n    file_attrs = struct.unpack_from('\u003CI', data, offset + 52)[0]\n    filename_len = struct.unpack_from('\u003CH', data, offset + 56)[0]\n    filename_off = struct.unpack_from('\u003CH', data, offset + 58)[0]\n\n    name = data[offset + filename_off:offset + filename_off + filename_len].decode('utf-16-le', errors='ignore')\n\n    # Convert Windows FILETIME to datetime\n    ts = datetime(1601, 1, 1) + timedelta(microseconds=timestamp \u002F\u002F 10)\n\n    # Decode reason flags\n    reasons = []\n    reason_flags = {\n        0x01: 'DATA_OVERWRITE', 0x02: 'DATA_EXTEND', 0x04: 'DATA_TRUNCATION',\n        0x10: 'NAMED_DATA_OVERWRITE', 0x20: 'NAMED_DATA_EXTEND',\n        0x100: 'FILE_CREATE', 0x200: 'FILE_DELETE', 0x400: 'EA_CHANGE',\n        0x800: 'SECURITY_CHANGE', 0x1000: 'RENAME_OLD_NAME', 0x2000: 'RENAME_NEW_NAME',\n        0x4000: 'INDEXABLE_CHANGE', 0x8000: 'BASIC_INFO_CHANGE',\n        0x10000: 'HARD_LINK_CHANGE', 0x20000: 'COMPRESSION_CHANGE',\n        0x40000: 'ENCRYPTION_CHANGE', 0x80000: 'OBJECT_ID_CHANGE',\n        0x100000: 'REPARSE_POINT_CHANGE', 0x200000: 'STREAM_CHANGE',\n        0x80000000: 'CLOSE'\n    }\n    for flag, desc in reason_flags.items():\n        if reason & flag:\n            reasons.append(desc)\n\n    record = {\n        'timestamp': ts.strftime('%Y-%m-%d %H:%M:%S'),\n        'filename': name,\n        'mft_entry': mft_ref,\n        'parent_entry': parent_ref,\n        'reasons': '|'.join(reasons),\n        'usn': usn\n    }\n\n    return record, offset + record_len\n\n# Parse the journal\nwith open('\u002Fcases\u002Fcase-2024-001\u002Fntfs\u002FUsnJrnl_J', 'rb') as f:\n    data = f.read()\n\nrecords = []\noffset = 0\nwhile offset \u003C len(data) - 8:\n    record, offset = parse_usn_record(data, offset)\n    if record:\n        records.append(record)\n    else:\n        offset += 8  # Skip zeros\n\n# Filter for deletion events\ndeletions = [r for r in records if 'FILE_DELETE' in r['reasons']]\ncreations = [r for r in records if 'FILE_CREATE' in r['reasons']]\nrenames = [r for r in records if 'RENAME_NEW_NAME' in r['reasons']]\n\nprint(f\"Total USN records: {len(records)}\")\nprint(f\"File creations: {len(creations)}\")\nprint(f\"File deletions: {len(deletions)}\")\nprint(f\"File renames: {len(renames)}\")\n\nprint(\"\\n=== RECENT DELETIONS ===\")\nfor r in deletions[-20:]:\n    print(f\"  [{r['timestamp']}] DELETED: {r['filename']} (MFT#{r['mft_entry']})\")\n\n# Write full journal to CSV\nwith open('\u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fusn_journal.csv', 'w', newline='') as f:\n    writer = csv.DictWriter(f, fieldnames=['timestamp', 'filename', 'mft_entry', 'parent_entry', 'reasons', 'usn'])\n    writer.writeheader()\n    writer.writerows(records)\nPYEOF\n```\n\n### Step 5: Detect and Analyze Alternate Data Streams\n\n```bash\n# List all Alternate Data Streams in the image\nfind \u002Fmnt\u002Fevidence -exec getfattr -d {} \\; 2>\u002Fdev\u002Fnull | grep -i \"ads\\|zone\\|stream\"\n\n# Using Sleuth Kit to find ADS\nfls -r -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd | grep \":\" | \\\n   tee \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fads_list.txt\n\n# Extract specific ADS content\n# Format: icat image inode:ads_name\nicat -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd 14523:hidden_stream \\\n   > \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fextracted_ads.bin\n\n# Check Zone.Identifier streams (download origin tracking)\nfls -r -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd | grep \"Zone.Identifier\" | \\\n   while read line; do\n       inode=$(echo \"$line\" | awk '{print $2}' | tr -d ':')\n       echo \"=== $line ===\"\n       icat -o 2048 \u002Fcases\u002Fcase-2024-001\u002Fimages\u002Fevidence.dd \"${inode}:Zone.Identifier\" 2>\u002Fdev\u002Fnull\n       echo \"\"\n   done > \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002Fzone_identifiers.txt\n\n# Zone.Identifier content reveals:\n# [ZoneTransfer]\n# ZoneId=3          (3 = Internet, indicating file was downloaded)\n# ReferrerUrl=https:\u002F\u002Fmalicious-site.com\u002Fpayload.exe\n# HostUrl=https:\u002F\u002Fcdn.malicious-site.com\u002Fpayload.exe\n```\n\n## Key Concepts\n\n| Concept | Description |\n|---------|-------------|\n| File slack | Unused space between file end and cluster boundary containing residual data |\n| RAM slack | Portion of slack from file end to sector boundary (historically filled with RAM) |\n| MFT ($MFT) | Master File Table - NTFS metadata database with entries for every file |\n| USN Journal ($UsnJrnl) | Change journal recording all file\u002Fdirectory modifications on NTFS |\n| Alternate Data Streams | NTFS feature allowing multiple data streams per file (hidden storage) |\n| $STANDARD_INFORMATION | MFT attribute with timestamps modifiable by user-mode applications |\n| $FILE_NAME | MFT attribute with timestamps only modifiable by the kernel |\n| Timestomping | Anti-forensic technique modifying file timestamps to avoid detection |\n\n## Tools & Systems\n\n| Tool | Purpose |\n|------|---------|\n| MFTECmd | Eric Zimmerman MFT and USN Journal parser with CSV output |\n| MFTExplorer | Interactive GUI tool for MFT analysis |\n| analyzeMFT | Python MFT parser with CSV\u002FJSON output |\n| The Sleuth Kit | File system forensics toolkit (fls, icat, blkls, istat) |\n| bulk_extractor | Feature extraction from raw data including slack space |\n| NTFS Log Tracker | Tool for parsing $LogFile transaction records |\n| streams.exe | Sysinternals tool for listing NTFS Alternate Data Streams |\n| Plaso | Super-timeline tool parsing MFT and USN Journal |\n\n## Common Scenarios\n\n**Scenario 1: Anti-Forensics Detection via Timestomping**\nCompare $STANDARD_INFORMATION timestamps with $FILE_NAME timestamps in MFT entries, flag files where $SI timestamps predate $FN timestamps (impossible in normal operation), identify timestomped files as evidence of deliberate manipulation, correlate with other timeline evidence.\n\n**Scenario 2: Hidden Data in Alternate Data Streams**\nScan for ADS attached to files beyond the standard Zone.Identifier, extract ADS content for analysis, check for hidden executables or documents stored in ADS, correlate ADS creation with user activity timeline, document findings for evidence.\n\n**Scenario 3: Deleted File Reconstruction from MFT**\nParse MFT for inactive (deleted) entries, extract filenames, sizes, and timestamps of deleted files, recover file content using icat if data clusters are not overwritten, build list of deleted evidence files, correlate with USN Journal delete events.\n\n**Scenario 4: File Activity Reconstruction from USN Journal**\nParse the USN Change Journal for the investigation period, identify file creation, modification, rename, and deletion events, reconstruct the sequence of file operations, detect evidence of data staging (create, copy, compress, delete pattern), identify anti-forensic file wiping.\n\n## Output Format\n\n```\nFile System Artifact Analysis:\n  Volume: NTFS (Partition 2, 465 GB)\n  Cluster Size: 4096 bytes\n\n  MFT Analysis:\n    Total Entries: 456,789\n    Active Files: 234,567\n    Deleted Entries: 12,345 (8,901 with recoverable metadata)\n    Timestomped Files: 23 (SI\u002FFN mismatch detected)\n\n  USN Journal:\n    Records Parsed: 2,345,678\n    Date Range: 2024-01-01 to 2024-01-20\n    File Creations: 45,678\n    File Deletions: 23,456\n    File Renames: 12,345\n\n  Alternate Data Streams:\n    Total ADS Found: 1,234\n    Zone.Identifier: 890 (downloaded files)\n    Custom\u002FSuspicious ADS: 5 (hidden data detected)\n\n  Slack Space:\n    Total Slack: 12.3 GB\n    Keyword Hits: 45 (passwords, credit cards)\n    Carved Files: 23 from slack space\n\n  Suspicious Findings:\n    - 23 files with timestomped timestamps\n    - 5 files with hidden ADS containing data\n    - USN shows mass deletion on 2024-01-18 (anti-forensics)\n    - Slack space contains residual email fragments\n\n  Reports: \u002Fcases\u002Fcase-2024-001\u002Fanalysis\u002F\n```\n",{"name":5,"tags":25,"author":33,"domain":34,"license":15,"version":35,"nist_csf":36,"subdomain":40,"description":7,"mitre_attack":41},[26,27,28,29,30,31,32],"forensics","slack-space","ntfs","mft","usn-journal","alternate-data-streams","file-system-analysis","mahipal","cybersecurity","1.0",[37,38,39],"RS.AN-03","DE.AE-02","RS.MA-01","digital-forensics",[42,43,44,45,46],"T1070.006","T1564.004","T1070.004","T1005","T1006","main","4e084e84eb42fc53e144c89c0f7f48b39c8a4b0f","collections\u002Fcybersecurity-skills\u002Fskills\u002Fanalyzing-slack-space-and-file-system-artifacts",1,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills","https:\u002F\u002Fgithub.com\u002Fsanjeevafk","First make it work. Then make it right. Then make it fast.","2026-11-14 13:36:16",{"source":8,"skillName":5,"commands":56,"prompt":66,"zipAvailable":67},[57,60,63],{"tool":58,"command":59},"npx","npx skills add sanjeevafk\u002Fagent-skills --skill analyzing-slack-space-and-file-system-artifacts",{"tool":61,"command":62},"bunx","bunx skills add sanjeevafk\u002Fagent-skills --skill analyzing-slack-space-and-file-system-artifacts",{"tool":64,"command":65},"pnpm","pnpm dlx skills add sanjeevafk\u002Fagent-skills --skill analyzing-slack-space-and-file-system-artifacts","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fanalyzing-slack-space-and-file-system-artifacts\u002FSKILL.md",true,[69,73,79],{"path":70,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":72,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":74,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Fapi-reference.md","REFERENCE","参考文档",1933,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fanalyzing-slack-space-and-file-system-artifacts\u002Freferences\u002Fapi-reference.md",{"path":80,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":83,"sourceHtmlUrl":84},"scripts\u002Fagent.py","SCRIPT","脚本",6680,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fanalyzing-slack-space-and-file-system-artifacts\u002Fscripts\u002Fagent.py",[86,94,102,110,118,125],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":90,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":20},"01M7EFHX67M3KKXT1BXVPA5ADT","zarr-python","Chunked N-D arrays for cloud storage (Zarr-Python 3). Compressed arrays, parallel I\u002FO, S3\u002FGCS via fsspec, NumPy\u002FDask\u002FXarray compatible, for large-scale scientific computing pipelines.","MIT","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzarr-python\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":90,"licenseFileUrl":98,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":20},"01M7EFFQGM51TZBGRENXY50ZYM","whiteboard-diagrams","Create accurate, simple, hand-drawn whiteboard diagrams from a user's process, system, architecture, learning workflow, comparison, or causal explanation. Use when the user asks for a scribbly whiteboard visual, educational workflow graphic, hand-drawn explainer, or diagram like the bundled reference; ask one focused clarification question when the subject or relationships are missing, then generate and visually verify the final image.","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwhiteboard-diagrams\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwhiteboard-diagrams\u002FSKILL.md",[],[],{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":106,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":20},"01M7EFF1CSQNTDMHFK4ZGY6NYK","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":114,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":20},"01M7EFE8106X6C28FT8PA74427","web-artifacts-builder","Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn\u002Fui). Use for complex artifacts requiring state management, routing, or shadcn\u002Fui components - not for simple single-file HTML\u002FJSX artifacts.","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fweb-artifacts-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fweb-artifacts-builder\u002FSKILL.md",[],[],{"skillNo":119,"name":120,"nameZh":6,"description":121,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":90,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":124,"publishedAt":20},"01M7EFCSNZM9G7ZHS6F127Q71X","verification-loop","A comprehensive verification system for Claude Code sessions.","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fverification-loop\u002FSKILL.md",[],[],{"skillNo":126,"name":127,"nameZh":6,"description":128,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":90,"licenseFileUrl":129,"sourceHtmlUrl":130,"categories":131,"keywords":132,"publishedAt":20},"01M7EFCE7EZMKPRYDDNKBQ9EEH","vercel-deploy","Deploy applications and websites to Vercel. Use when the user requests deployment actions like \"deploy my app\", \"deploy and give me the link\", \"push this live\", or \"create a preview deployment\".","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fvercel-deploy\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fvercel-deploy\u002FSKILL.md",[],[]]