Communitygithub.com

MFT分析による削除ファイル復元

NTFSマスターファイルテーブル($MFT)をMFTECmdやanalyzeMFTで分析し、削除されたファイルの復元とフォレンジック調査を行うスキルです。

MFT分析による削除ファイル復元 とは?

このスキルは、NTFSボリューム上の削除ファイル復元に特化したフォレンジック分析手順を提供します。$MFT(マスターファイルテーブル)はNTFSの中心的なメタデータリポジトリであり、各ファイルのレコードにはタイムスタンプ、パーミッション、ファイル名、データ配置情報などが含まれています。ファイル削除後もこのレコードはすぐには上書きされないため、MFT解析は削除ファイルの証拠復元やファイルシステムタイムラインの再構築、タイムスタンプ操作(timestomping)などのアンチフォレンジック検出に極めて有効です。対応ツールとしてはMFTECmd(Eric Zimmerman製)やanalyzeMFT(Python製)を使用し、CSV出力をTimeline ExplorerやExcelで分析します。具体的な復元手法として、MFTレコードのInUseフラグ判定、USNジャーナル解析、$LogFileトランザクション解析、MFTスラックスペース分析の4つを網羅。さらに、$Recycle.BinやVolume Shadow Copyとのクロスリファレンスによる証拠相関もサポートします。このスキルは、セキュリティインシデント調査、検知ルール開発、SOCアナリストの手順書、監視カバレッジ検証などに活用できます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/analyzing-mft-for-deleted-file-recovery

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

削除ファイル復元のためのMFT分析

概要

NTFSマスターファイルテーブル($MFT)は、NTFSボリューム上のすべてのファイルとディレクトリの中心的なメタデータリポジトリです。各ファイルは少なくとも1つの1024バイトのMFTレコードで表され、$STANDARD_INFORMATION(タイムスタンプ、アクセス権限)、$FILE_NAME(ファイル名、親ディレクトリ、タイムスタンプ)、$DATA(ファイル内容またはクラスタ実行ポインタ)などの属性が含まれます。ファイルが削除されると、そのMFTレコードは非アクティブとしてマークされます(InUseフラグがクリアされる)が、新しいファイルによってエントリが再割り当てされるまでメタデータは残り続けます。この永続性により、MFT分析は削除ファイルの証拠復元、ファイルシステムタイムラインの再構築、およびタイムスタンプ操作(timestomping)などのアンチフォレンジックアクティビティの検出のための主要な手法となっています。

使用タイミング

  • 削除ファイル復元のためにMFT分析を必要とするセキュリティインシデントを調査する場合
  • このドメイン向けの検知ルールや脅威ハンティングクエリを構築する場合
  • SOCアナリストがこの分析タイプのための構造化された手順を必要とする場合
  • 関連する攻撃テクニックに対するセキュリティ監視カバレッジを検証する場合

前提条件

  • フォレンジックディスクイメージ(E01、raw/dd、VMDK、またはVHDX形式)
  • MFTECmd(Eric Zimmerman)またはanalyzeMFT(Pythonベース)
  • FTK Imager、Arsenal Image Mounter、または同様のイメージマウントツール
  • Timeline ExplorerまたはExcel(CSV分析用)
  • Python 3.8以上(カスタム分析スクリプト用)
  • NTFSファイルシステム内部構造の理解

MFT構造とレコードレイアウト

MFTレコードヘッダー

各MFTレコードはシグネチャ「FILE」(0x46494C45)で始まり、以下を含みます:

オフセットサイズフィールド
0x004バイトシグネチャ(「FILE」)
0x042バイト更新シーケンスへのオフセット
0x062バイト更新シーケンスのサイズ
0x088バイト$LogFileシーケンス番号
0x102バイトシーケンス番号
0x122バイトハードリンク数
0x142バイト最初の属性へのオフセット
0x162バイトフラグ(0x01 = InUse、0x02 = ディレクトリ)
0x184バイトMFTレコードの使用サイズ
0x1C4バイトMFTレコードの割り当てサイズ
0x208バイトベースファイルレコード参照
0x282バイト次の属性ID

主要なMFT属性

タイプID名前説明
0x10$STANDARD_INFORMATIONタイムスタンプ、フラグ、所有者ID、セキュリティID
0x30$FILE_NAMEファイル名、親MFT参照、タイムスタンプ
0x40$OBJECT_IDファイルの一意のGUID
0x50$SECURITY_DESCRIPTORACLアクセス権限
0x60$VOLUME_NAMEボリュームラベル(ボリュームメタデータファイルのみ)
0x80$DATAファイル内容(700バイト未満の場合は常駐)またはクラスタ実行リスト
0x90$INDEX_ROOTディレクトリ用のB-treeインデックスルート
0xA0$INDEX_ALLOCATION大規模ディレクトリ用のB-treeインデックスエントリ
0xB0$BITMAPインデックスまたはMFTの割り当てビットマップ

削除ファイル復元テクニック

テクニック1:MFTECmdによるMFTレコード分析

# KAPEまたはFTK Imagerを使用してフォレンジックイメージから$MFTを抽出
# MFTECmdで$MFTを解析
MFTECmd.exe -f "C:\Evidence\$MFT" --csv C:\Output --csvf mft_full.csv

# Timeline Explorerで削除ファイルをフィルタリング(InUse = FALSE)
# InUse列がFalseであるエントリを探す

CSV出力での削除ファイルの識別方法:

  • InUse = Falseは削除または再割り当てされたレコードを示す
  • ParentPathは削除前の元のファイル場所を示す
  • FileSizeは元のサイズを示す(復元可能な場合がある)
  • $STANDARD_INFORMATIONと$FILE_NAME属性のタイムスタンプは保持される

テクニック2:USNジャーナル($UsnJrnl:$J)分析

USNジャーナルは、NTFSボリューム上のすべてのファイル変更(作成、削除、名前変更、データ変更イベント)を記録します。

# MFTECmdでUSNジャーナルを解析
MFTECmd.exe -f "C:\Evidence\$J" --csv C:\Output --csvf usn_journal.csv

# 削除証拠に関する主要なUSN理由コード:
# USN_REASON_FILE_DELETE     = 0x00000200
# USN_REASON_CLOSE           = 0x80000000
# USN_REASON_RENAME_OLD_NAME = 0x00001000
# USN_REASON_RENAME_NEW_NAME = 0x00002000

テクニック3:$LogFileトランザクション分析

$LogFileはNTFSトランザクションレコードを保存しており、USNジャーナルが循環された後でもファイル操作を明らかにできます。

# LogFileParserで$LogFileを解析
LogFileParser.exe -l "C:\Evidence\$LogFile" -o C:\Output

# ファイル削除を示すREDOおよびUNDO操作を探す:
# - DeallocateFileRecordSegment
# - DeleteAttribute
# - UpdateResidentValue(InUseフラグのクリア)

テクニック4:MFTスラックスペース分析

MFTスラックスペースは、MFTレコードの使用部分の終わりから割り当てられた1024バイトの終わりまでの間に存在します。この領域には、以前のファイルレコードの残骸が含まれている可能性があります。

import struct

def parse_mft_slack(mft_path: str, output_path: str):
    """削除ファイルの残骸を抽出・分析するためにMFTスラックスペースを解析します。"""
    with open(mft_path, "rb") as f:
        record_size = 1024
        record_num = 0
        slack_findings = []

        while True:
            record = f.read(record_size)
            if len(record) < record_size:
                break

            # FILEシグネチャを確認
            if record[:4] != b"FILE":
                record_num += 1
                continue

            # オフセット0x18から使用サイズを取得
            used_size = struct.unpack("<I", record[0x18:0x1C])[0]

            if used_size < record_size:
                slack = record[used_size:]
                # スラックに読み取り可能な文字列または属性ヘッダーが含まれているか確認
                if any(c > 0x20 and c < 0x7F for c in slack[:50]):
                    slack_findings.append({
                        "record": record_num,
                        "used_size": used_size,
                        "slack_size": record_size - used_size,
                        "slack_preview": slack[:100].hex()
                    })

            record_num += 1

    return slack_findings

関連アーティファクトとの相関

MFTと$Recycle.Binのクロスリファレンス

# RBCmdでリサイクルビンを解析
RBCmd.exe -d "C:\Evidence\$Recycle.Bin" --csv C:\Output --csvf recycle_bin.csv

# 相関:$Iファイルには元のパスと削除タイムスタンプが含まれる
# $RファイルからMFTエントリ番号を元のMFTレコードにマッチング

MFTとボリュームシャドウコピーのクロスリファレンス

# ボリュームシャドウコピーを一覧表示
vssadmin list shadows

# シャドウコピーをマウントし、それぞれから$MFTを抽出
# シャドウコピー間でMFTレコードを比較し、経時的なファイル変更を追跡

フォレンジック価値

  • 削除ファイルのメタデータ復元:元のファイル名、パス、サイズ、タイムスタンプ
  • タイムライン再構築:ファイルの作成、変更、アクセス、削除イベント
  • タイムスタンプ操作の検出:$SIと$FNのタイムスタンプの比較
  • データカービングのガイダンス:MFTクラスタ実行がディスク上のファイル内容を指し示す
  • アンチフォレンジック検出:ワイプや改ざんされたMFTレコードの識別

参考資料

出力例

$ MFTECmd.exe -f "C:\Evidence\$MFT" --csv /analysis/mft_output

MFTECmd v1.2.2 - MFTパーサー
==============================
入力:C:\Evidence\$MFT(サイズ:384 MB)
総MFTエントリ数:395,264

MFTエントリを解析中... 完了(12.4秒)

--- 削除ファイル復元サマリー ---
総エントリ数:          395,264
アクティブファイル:     245,832
削除ファイル:          149,432
  復元可能:            87,234(常駐データ、またはクラスタが再割り当てされていない)
  部分的に復元可能:    31,456(一部のクラスタが上書きされている)
  復元不可:            30,742(すべてのクラスタが再割り当てされている)

--- 最近削除されたファイル(インシデント期間:2024-01-15から2024-01-18)---
MFTエントリ | ファイル名                    | パス                               | サイズ    | 削除日時(UTC)         | 復元可能
----------|-------------------------------|------------------------------------|-----------|-----------------------|------------
148923    | exfil_tool.exe                | C:\ProgramData\Updates\            | 1,258,496 | 2024-01-17 02:45:12   | はい
148924    | exfil_tool.log                | C:\ProgramData\Updates\            | 45,312    | 2024-01-17 02:45:14   | はい
149001    | passwords.txt                 | C:\Users\jsmith\Desktop\           | 2,048     | 2024-01-17 02:50:33   | はい
149150    | scan_results.csv              | C:\Users\jsmith\AppData\Local\Temp | 892,416   | 2024-01-17 03:00:01   | 部分的
149200    | mimikatz.exe                  | C:\Windows\Temp\                   | 1,250,816 | 2024-01-18 01:15:22   | はい
149201    | sekurlsa.log                  | C:\Windows\Temp\                   | 32,768    | 2024-01-18 01:15:25   | はい
149302    | .bash_history                 | C:\Users\jsmith\                   | 4,096     | 2024-01-18 03:00:00   | いいえ
149400    | ClearEventLogs.ps1            | C:\Windows\Temp\                   | 1,536     | 2024-01-18 03:01:12   | はい

--- $STANDARD_INFORMATION対$FILE_NAMEタイムスタンプ分析(タイムスタンプ操作検出)---
MFTエントリ | ファイル名          | $SI作成日時          | $FN作成日時          | 差分       | 判定
----------|---------------------|----------------------|----------------------|-----------|----------
148923    | exfil_tool.exe      | 2023-06-15 10:00:00  | 2024-01-15 14:34:02  | -214日    | タイムスタンプ改ざん
149200    | mimikatz.exe        | 2022-01-01 00:00:00  | 2024-01-16 02:30:15  | -745日    | タイムスタンプ改ざん

復元されたファイルの出力先:/analysis/mft_output/recovered/
完全なCSVレポート:/analysis/mft_output/mft_analysis.csv(395,264行)
タイムラインCSV:/analysis/mft_output/mft_timeline.csv

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

abusing-dpapi-for-credential-access

Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket

abusing-shadow-credentials-for-privesc

Take over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target

achieving-cmmc-level-2-compliance

>-

acquiring-disk-image-with-dd-and-dcfldd

Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.

analyzing-active-directory-acl-abuse

Detect dangerous ACL misconfigurations in Active Directory using ldap3

analyzing-android-malware-with-apktool

Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.

analyzing-api-gateway-access-logs

Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect

analyzing-apt-group-with-mitre-navigator

Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups

analyzing-azure-activity-logs-for-threats

Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query

analyzing-bootkit-and-rootkit-samples

Analyzes bootkit and advanced rootkit malware infecting the Master

analyzing-browser-forensics-with-hindsight

Parse Chromium-based browser databases with Hindsight to extract and correlate browsing history, downloads, cookies, cached content, autofill data, saved passwords, and extensions from Chrome, Edge, Brave, Opera, and Vivaldi into a unified timeline (XLSX, JSON, or SQLite output). Use during incident response, insider-threat investigations, or criminal cases when you need to reconstruct a user

analyzing-campaign-attribution-evidence

Systematically evaluate cyber-campaign evidence to attribute an operation to a threat actor, using the Diamond Model and Analysis of Competing Hypotheses (ACH) to weigh infrastructure overlaps, TTP consistency, malware code similarity, and timing/language artifacts into confidence-weighted attribution assessments. Use when an incident investigation needs a defensible attribution confidence level.

analyzing-certificate-transparency-for-phishing

Monitor Certificate Transparency logs using crt.sh and Certstream to

analyzing-cloud-storage-access-patterns

Detect abnormal access in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics for after-hours bulk downloads, new-IP access, and API-call spikes (e.g. GetObject) via statistical baselines and time-series anomaly detection. Use when investigating suspected cloud data exfiltration or building related detection rules.

analyzing-cobalt-strike-beacon-configuration

Extract and analyze Cobalt Strike beacon configuration from PE files

analyzing-cobaltstrike-malleable-c2-profiles

Parse and analyze Cobalt Strike Malleable C2 profiles with dissect.cobaltstrike (profiles and beacon-payload configs) and pyMalleableC2 (AST parsing) to extract HTTP/DNS transforms, URIs, headers, sleep/jitter, and injection behavior, then generate network detection signatures. Use when reverse-engineering a captured malleable profile or building detections against Cobalt Strike Beacon traffic.

analyzing-command-and-control-communication

Analyzes malware C2 communication over HTTP, HTTPS, DNS, and custom

analyzing-cyber-kill-chain

Analyzes intrusion activity against the Lockheed Martin Cyber Kill Chain

analyzing-disk-image-with-autopsy

Perform comprehensive forensic analysis of raw (dd), E01, or AFF disk images with Autopsy and The Sleuth Kit, recovering deleted files, examining metadata and embedded artifacts, keyword searching, and building investigation timelines with visual reports. Use for structured analysis of a forensic disk image or when stakeholders need visual reports from evidence.

analyzing-dns-logs-for-exfiltration

Analyzes DNS query logs to detect data exfiltration via DNS tunneling,

関連スキル