Communitygithub.com

プリフェッチファイル分析による実行履歴調査

Windows プリフェッチファイル(バージョン17、23、26、30)をPECmd、WinPrefetchView、python-prefetchなどのツールで解析し、実行回数、実行タイムスタンプ、参照ファイル/DLLなどのプログラム実行履歴を特定します。Windowsシステムでのプログラム実行タイムラインの構築、不審なバイナリの実行確認、調査中の他のフォレンジック証拠との実行証跡の関連付けに使用します。

プリフェッチファイル分析による実行履歴調査 とは?

このスキルは、Windows プリフェッチファイル(.pf)を解析してプログラム実行履歴を詳細に調査します。プリフェッチはWindowsのパフォーマンス最適化機能であり、アプリケーションの起動情報を記録するため、フォレンジック調査において「どのプログラムがいつ実行されたか」を確認する貴重な証拠源となります。本スキルは、PECmd(Eric Zimmerman製)、WinPrefetchView、python-prefetchライブラリといった主要な解析ツールをサポートし、コマンドラインとPythonスクリプトの両方でのワークフローを提供します。主な解析項目は、実行可能ファイル名、実行回数(最大8つのタイムスタンプ)、参照されたファイルやDLLリスト、ボリューム情報です。マルウェア実行の確認、攻撃者ツールの使用タイムラインの構築、データ持ち出しツールの検出、アンチフォレンジックツールの特定といった複数の実戦シナリオをカバーしています。出力はCSV/JSON形式で、他のフォレンジックアーティファクト(Shimcache、Amcacheなど)とのクロスリファレンスが可能です。Windows 10のMAM圧縮形式にも対応し、必要に応じて圧縮解除を行います。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/analyzing-prefetch-files-for-execution-history

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

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

ドキュメント

プリフェッチファイル分析による実行履歴調査 は何をしますか?

使用すべき場面

  • Windowsシステムで実行されたプログラムとその実行時刻を特定する必要がある場合
  • マルウェア調査において不審なバイナリの実行を確認する場合
  • インシデント中のアプリケーション使用状況のタイムラインを構築する場合
  • プログラム実行を他のフォレンジック証拠と関連付ける場合
  • アンチフォレンジックツールや不正なソフトウェアの実行を特定する場合

前提条件

  • フォレンジックイメージからWindows Prefetchディレクトリ(C:\Windows\Prefetch\)にアクセスできること
  • PECmd(Eric Zimmerman)、WinPrefetchView、またはpython-prefetchパーサーが利用可能であること
  • プリフェッチファイル形式(バージョン17、23、26、30)に関する知識
  • Prefetchが有効なWindowsシステム(クライアントOSではデフォルト有効、サーバーでは無効)
  • プリフェッチの命名規則(APPNAME-HASH.pf)の理解

ワークフロー

ステップ1:フォレンジックイメージからプリフェッチファイルを抽出

# フォレンジックイメージをマウント
mount -o ro,loop,offset=$((2048*512)) /cases/case-2024-001/images/evidence.dd /mnt/evidence

# すべてのプリフェッチファイルをコピー
mkdir -p /cases/case-2024-001/prefetch/
cp /mnt/evidence/Windows/Prefetch/*.pf /cases/case-2024-001/prefetch/

# プリフェッチファイルの数とリストを確認
ls -la /cases/case-2024-001/prefetch/ | wc -l
ls -la /cases/case-2024-001/prefetch/ | head -30

# すべてのプリフェッチファイルのハッシュを取得(完全性確認用)
sha256sum /cases/case-2024-001/prefetch/*.pf > /cases/case-2024-001/prefetch/pf_hashes.txt

# 注:プリフェッチファイル名の形式は EXECUTABLE_NAME-XXXXXXXX.pf
# ハッシュ(XXXXXXXX)は実行可能ファイルのパスに基づく
# 同一の実行ファイルでもパスが異なると別のプリフェッチファイルが作成される

ステップ2:PECmdでプリフェッチファイルを解析

# Eric ZimmermanのPECmdを使用(Windows、またはLinux上のMono/Wine経由)
# ダウンロード先: https://ericzimmerman.github.io/

# 単一のプリフェッチファイルを解析
PECmd.exe -f "C:\cases\prefetch\POWERSHELL.EXE-A]B2C3D4.pf"

# すべてのプリフェッチファイルを解析しCSV出力
PECmd.exe -d "C:\cases\prefetch\" --csv "C:\cases\analysis\" --csvf prefetch_results.csv

# JSON出力で解析
PECmd.exe -d "C:\cases\prefetch\" --json "C:\cases\analysis\" --jsonf prefetch_results.json

# 各ファイルについて以下の情報を出力:
# - 実行可能ファイル名とパス
# - 実行回数
# - 最終実行時刻(Windows 10では最大8タイムスタンプ)
# - 実行中に参照されたファイルとディレクトリ
# - ボリューム情報(シリアル番号、作成日)
# - プリフェッチファイル作成時刻

ステップ3:Linux環境でのPython解析

pip install prefetch

python3 << 'PYEOF'
import os
import json
from datetime import datetime

# pythonを使用してプリフェッチファイルを解析
import struct

def parse_prefetch(filepath):
    """Windows Prefetchファイルを解析する。"""
    with open(filepath, 'rb') as f:
        data = f.read()

    # MAM圧縮形式(Windows 10)の確認
    if data[:4] == b'MAM\x04':
        import lznt1  # または DecompressBuffer を使用
        # Windows 10のプリフェッチファイルは圧縮されている
        print(f"  [圧縮Win10形式 - 完全解析にはPECmdを使用してください]")
        return None

    # バージョン 17 (XP), 23 (Vista/7), 26 (8.1), 30 (10)
    version = struct.unpack('<I', data[0:4])[0]
    signature = data[4:8]

    if signature != b'SCCA':
        print(f"  無効なプリフェッチシグネチャ")
        return None

    file_size = struct.unpack('<I', data[8:12])[0]
    exec_name = data[16:76].decode('utf-16-le').strip('\x00')
    run_count = struct.unpack('<I', data[208:212])[0] if version >= 23 else struct.unpack('<I', data[144:148])[0]

    result = {
        'version': version,
        'executable': exec_name,
        'file_size': file_size,
        'run_count': run_count,
    }

    # 最終実行タイムスタンプの抽出
    if version == 23:  # Vista/7 - 1タイムスタンプ
        ts = struct.unpack('<Q', data[128:136])[0]
        result['last_run'] = filetime_to_datetime(ts)
    elif version >= 26:  # Win8+ - 最大8タイムスタンプ
        timestamps = []
        for i in range(8):
            ts = struct.unpack('<Q', data[128+i*8:136+i*8])[0]
            if ts > 0:
                timestamps.append(filetime_to_datetime(ts))
        result['last_run_times'] = timestamps

    return result

def filetime_to_datetime(ft):
    """Windows FILETIMEを日時文字列に変換する。"""
    if ft == 0:
        return None
    timestamp = (ft - 116444736000000000) / 10000000
    try:
        return datetime.utcfromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S UTC')
    except (OSError, ValueError):
        return None

# すべてのプリフェッチファイルを処理
prefetch_dir = '/cases/case-2024-001/prefetch/'
results = []

for filename in sorted(os.listdir(prefetch_dir)):
    if filename.lower().endswith('.pf'):
        filepath = os.path.join(prefetch_dir, filename)
        print(f"\n=== {filename} ===")
        result = parse_prefetch(filepath)
        if result:
            print(f"  実行ファイル: {result['executable']}")
            print(f"  実行回数:     {result['run_count']}")
            if 'last_run' in result:
                print(f"  最終実行:     {result['last_run']}")
            elif 'last_run_times' in result:
                for i, ts in enumerate(result['last_run_times']):
                    print(f"  実行時刻 {i+1}: {ts}")
            results.append(result)

# 結果を保存
with open('/cases/case-2024-001/analysis/prefetch_analysis.json', 'w') as f:
    json.dump(results, f, indent=2)
PYEOF

ステップ4:不審な実行証跡を特定

# 既知の悪意あるツール名をプリフェッチから検索
ls /cases/case-2024-001/prefetch/ | grep -iE \
   '(MIMIKATZ|PSEXEC|WMIC|COBALT|BEACON|PWDUMP|PROCDUMP|LAZAGNE|RUBEUS|BLOODHOUND|SHARPHOUND|CERTUTIL|BITSADMIN)'

# スクリプトインタープリタを検索(悪意のある実行の可能性)
ls /cases/case-2024-001/prefetch/ | grep -iE \
   '(POWERSHELL|CMD\.EXE|WSCRIPT|CSCRIPT|MSHTA|REGSVR32|RUNDLL32|MSIEXEC)'

# リモートアクセスツールを検索
ls /cases/case-2024-001/prefetch/ | grep -iE \
   '(TEAMVIEWER|ANYDESK|LOGMEIN|VNC|SPLASHTOP|SCREENCONNECT|AMMYY)'

# データ流出ツールを検索
ls /cases/case-2024-001/prefetch/ | grep -iE \
   '(RAR|7Z|ZIP|RCLONE|MEGA|DROPBOX|ONEDRIVE|GDRIVE|FTP|CURL|WGET)'

# 最近作成されたプリフェッチファイル(最も新しい実行ファイル)を検索
ls -lt /cases/case-2024-001/prefetch/ | head -20

# ShimcacheやAmcacheと相互参照して確認
# プリフェッチが存在する = プログラムが少なくとも1回実行された

ステップ5:実行タイムラインの構築

# プリフェッチデータからタイムラインを作成
python3 << 'PYEOF'
import json
import csv

with open('/cases/case-2024-001/analysis/prefetch_analysis.json') as f:
    data = json.load(f)

timeline = []
for entry in data:
    if 'last_run_times' in entry:
        for ts in entry['last_run_times']:
            if ts:
                timeline.append({
                    'timestamp': ts,
                    'executable': entry['executable'],
                    'run_count': entry['run_count'],
                    'source': 'Prefetch'
                })
    elif 'last_run' in entry and entry['last_run']:
        timeline.append({
            'timestamp': entry['last_run'],
            'executable': entry['executable'],
            'run_count': entry['run_count'],
            'source': 'Prefetch'
        })

# 時系列順に並べ替え
timeline.sort(key=lambda x: x['timestamp'])

# タイムラインCSVを書き出し
with open('/cases/case-2024-001/analysis/execution_timeline.csv', 'w', newline='') as f:
    writer = csv.DictWriter(f, fieldnames=['timestamp', 'executable', 'run_count', 'source'])
    writer.writeheader()
    writer.writerows(timeline)

# 不審な時間帯のエントリを出力
for entry in timeline:
    if '2024-01-15' in entry['timestamp'] or '2024-01-16' in entry['timestamp']:
        print(f"  {entry['timestamp']} | {entry['executable']} (x{entry['run_count']})")
PYEOF

主要な概念

概念説明
PrefetchWindowsのパフォーマンス最適化機能。アプリケーションデータのプリロードと実行追跡を行う
SCCAシグネチャ有効なプリフェッチファイルを示すマジックバイト
パスハッシュ実行可能ファイルパスのCRCベースのハッシュで、.pfファイル名の一部を構成
実行回数実行可能ファイルが起動された回数(ラップアラウンドする可能性あり)
最終実行タイムスタンプWindows 8+では最大8つの最近の実行タイムスタンプを保存
参照ファイル実行開始から最初の10秒間にアクセスされたファイルとディレクトリのリスト
ボリューム情報ソースボリュームを識別するドライブのシリアル番号と作成日
MAM圧縮Windows 10のプリフェッチファイルはMAM4圧縮を使用。解析前に解凍が必要

ツールとシステム

ツール目的
PECmdEric Zimmerman製のプリフェッチパーサー。CSV/JSON出力対応
WinPrefetchViewNirSoft製のGUIツール。プリフェッチファイルを表示
python-prefetchプリフェッチファイル解析のためのPythonライブラリ
Prefetch Hash Calculator実行可能パスから期待されるハッシュを計算するツール
KAPEプリフェッチを含む自動フォレンジック証拠収集ツール
Autopsyプリフェッチ分析モジュールを備えたフォレンジックプラットフォーム
Plaso/log2timelineプリフェッチパーサーを含むスーパータイムラインツール
Velociraptorプリフェッチ収集・分析アーティファクトを持つエンドポイントエージェント

よくあるシナリオ

シナリオ1:マルウェア実行の確認 プリフェッチディレクトリでマルウェアの実行ファイル名を検索し、プリフェッチの存在で実行を確認。実行回数と最終実行時刻を抽出。参照されたDLLを特定してマルウェアの動作を理解。レジストリの自動起動エントリと関連付け。

シナリオ2:攻撃者ツールの使用タイムライン PsExec、Mimikatz、BloodHoundなど攻撃者ツールのプリフェッチファイルを特定。時系列のツール実行タイムラインを構築。攻撃の順序(偵察、認証情報窃取、横方向移動)を特定。タイムスタンプをネットワーク接続ログと照合。

シナリオ3:データのステージングと持ち出し 圧縮ツール(7z、WinRAR、zip)のプリフェッチエントリを確認。ファイル転送ユーティリティ(rclone、FTPクライアント)の実行を特定。クラウドストレージクライアントの実行を確認。データのステージングと転送が行われた時間を特定。

シナリオ4:アンチフォレンジックの検出 既知のアンチフォレンジックツール(CCleaner、Eraser、SDelete)の実行を確認。プリフェッチディレクトリが最近クリアされたかどうかを確認(アクティブなシステムで想定されるよりもファイル数が少ない)。アンチフォレンジックツールの実行タイムスタンプを他の証拠と比較。

出力形式

PreFetch分析サマリ:
  システム: Windows 10 Pro (Build 19041)
  プリフェッチファイル数: 234
  分析期間: 利用可能な全実行履歴

  実行統計:
    一意の実行ファイル総数: 234
    最初の実行: 2023-06-15 (システムインストール時)
    最新の実行: 2024-01-18 23:45 UTC

  不審な実行:
    MIMIKATZ.EXE-5F2A3B1C.pf
      実行回数: 3 | 最終実行: 2024-01-16 02:30:15 UTC
    PSEXEC.EXE-AD70946C.pf
      実行回数: 7 | 最終実行: 2024-01-16 02:45:30 UTC
    RCLONE.EXE-1F3E5A2B.pf
      実行回数: 2 | 最終実行: 2024-01-17 03:15:00 UTC
    POWERSHELL.EXE-022A1004.pf
      実行回数: 145 | 最終実行: 2024-01-18 14:00:00 UTC

  攻撃タイムライン(Prefetchから):
    2024-01-15 14:32 - POWERSHELL.EXE (初期アクセス)
    2024-01-16 02:30 - MIMIKATZ.EXE (認証情報窃取)
    2024-01-16 02:45 - PSEXEC.EXE (横方向移動)
    2024-01-17 03:15 - RCLONE.EXE (データ流出)

  レポート: /cases/case-2024-001/analysis/execution_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,

関連スキル