analyzing-windows-registry-for-artifacts について
Windows レジストリハイブを調べ、システムやユーザー活動の痕跡を抽出するデジタルフォレンジック用スキルです。RegRipper や python-registry などを使う調査手順を示します。
主な機能
- 01レジストリハイブの抽出
- 02RegRipper による痕跡分析
- 03永続化・自動起動項目の調査
- 04ユーザー活動の再構成
- 05システム・ネットワーク情報の抽出
活用シーン
- 01マルウェアの永続化調査
- 02インシデント前後のユーザー操作の再構成
- 03未承認インストールソフトの検出
- 04情報持ち出し調査での USB デバイス利用追跡
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ mukul975/ anthropic-cybersecurity-skills --skill analyzing-windows-registry-for-artifactsインストール後、Claude Code で/analyzing-windows-registry-for-artifactsを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
LICENSEreferences/api-reference.mdscripts/agent.py詳細
アーティファクトを特定するための Windows レジストリ分析
使用する場面
- インシデント発生時に Windows システム上のユーザーアクティビティを調査する場合
- マルウェアが使用する自動実行/永続化の仕組みを特定する場合
- インストール済みソフトウェア、USB デバイス、ネットワーク接続を追跡する場合
- インサイダー脅威の調査でユーザーの操作を再構成する場合
- レジストリのタイムスタンプをほかのフォレンジックアーティファクトと関連付ける場合
前提条件
- フォレンジックイメージ、または抽出済みのレジストリハイブファイル
- RegRipper、Registry Explorer (Eric Zimmerman)、または python-registry
- レジストリハイブの保存場所(SAM、SYSTEM、SOFTWARE、NTUSER.DAT、UsrClass.dat)へのアクセス
- Windows レジストリの構造(ハイブ、キー、値)に関する理解
- SIFT Workstation またはフォレンジック分析環境
ワークフロー
手順 1:フォレンジックイメージからレジストリハイブを抽出する
# Mount the forensic image read-only
mkdir /mnt/evidence
mount -o ro,loop,offset=$((2048*512)) /cases/case-2024-001/images/evidence.dd /mnt/evidence
# Copy system registry hives
cp /mnt/evidence/Windows/System32/config/SAM /cases/case-2024-001/registry/
cp /mnt/evidence/Windows/System32/config/SYSTEM /cases/case-2024-001/registry/
cp /mnt/evidence/Windows/System32/config/SOFTWARE /cases/case-2024-001/registry/
cp /mnt/evidence/Windows/System32/config/SECURITY /cases/case-2024-001/registry/
cp /mnt/evidence/Windows/System32/config/DEFAULT /cases/case-2024-001/registry/
# Copy user-specific hives
cp /mnt/evidence/Users/*/NTUSER.DAT /cases/case-2024-001/registry/
cp /mnt/evidence/Users/*/AppData/Local/Microsoft/Windows/UsrClass.dat /cases/case-2024-001/registry/
# Copy transaction logs (for dirty hive recovery)
cp /mnt/evidence/Windows/System32/config/*.LOG* /cases/case-2024-001/registry/logs/
# Hash all extracted hives
sha256sum /cases/case-2024-001/registry/* > /cases/case-2024-001/registry/hive_hashes.txt
手順 2:RegRipper で自動アーティファクト抽出を実行する
# Install RegRipper
git clone https://github.com/keydet89/RegRipper3.0.git /opt/regripper
# Run RegRipper against NTUSER.DAT (user profile)
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/NTUSER.DAT \
-f ntuser > /cases/case-2024-001/analysis/ntuser_report.txt
# Run against SYSTEM hive
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SYSTEM \
-f system > /cases/case-2024-001/analysis/system_report.txt
# Run against SOFTWARE hive
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SOFTWARE \
-f software > /cases/case-2024-001/analysis/software_report.txt
# Run against SAM hive (user accounts)
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SAM \
-f sam > /cases/case-2024-001/analysis/sam_report.txt
# Run specific plugins
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/NTUSER.DAT \
-p userassist > /cases/case-2024-001/analysis/userassist.txt
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SYSTEM \
-p usbstor > /cases/case-2024-001/analysis/usbstor.txt
手順 3:永続化および自動実行エントリを抽出する
# Using python-registry for targeted extraction
pip install python-registry
python3 << 'PYEOF'
from Registry import Registry
# Open SOFTWARE hive
reg = Registry.Registry("/cases/case-2024-001/registry/SOFTWARE")
# Check Run keys (autostart)
autorun_paths = [
"Microsoft\\Windows\\CurrentVersion\\Run",
"Microsoft\\Windows\\CurrentVersion\\RunOnce",
"Microsoft\\Windows\\CurrentVersion\\RunServices",
"Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run",
"Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run"
]
for path in autorun_paths:
try:
key = reg.open(path)
print(f"\n=== {path} (Last Modified: {key.timestamp()}) ===")
for value in key.values():
print(f" {value.name()}: {value.value()}")
except Registry.RegistryKeyNotFoundException:
pass
# Check installed services
key = reg.open("Microsoft\\Windows NT\\CurrentVersion\\Svchost")
print(f"\n=== Svchost Groups ===")
for value in key.values():
print(f" {value.name()}: {value.value()}")
PYEOF
# Check NTUSER.DAT for user-specific autorun
python3 << 'PYEOF'
from Registry import Registry
reg = Registry.Registry("/cases/case-2024-001/registry/NTUSER.DAT")
user_autorun = [
"Software\\Microsoft\\Windows\\CurrentVersion\\Run",
"Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce",
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartupApproved\\Run"
]
for path in user_autorun:
try:
key = reg.open(path)
print(f"\n=== {path} (Last Modified: {key.timestamp()}) ===")
for value in key.values():
print(f" {value.name()}: {value.value()}")
except Registry.RegistryKeyNotFoundException:
pass
PYEOF
手順 4:ユーザーアクティビティのアーティファクトを分析する
# Extract UserAssist data (program execution history with ROT13 encoding)
python3 << 'PYEOF'
from Registry import Registry
import codecs, struct, datetime
reg = Registry.Registry("/cases/case-2024-001/registry/NTUSER.DAT")
ua_path = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\UserAssist"
key = reg.open(ua_path)
for guid_key in key.subkeys():
count_key = guid_key.subkey("Count")
print(f"\n=== {guid_key.name()} ===")
for value in count_key.values():
decoded_name = codecs.decode(value.name(), 'rot_13')
data = value.value()
if len(data) >= 16:
run_count = struct.unpack('<I', data[4:8])[0]
focus_count = struct.unpack('<I', data[8:12])[0]
timestamp = struct.unpack('<Q', data[60:68])[0] if len(data) >= 68 else 0
if timestamp > 0:
ts = datetime.datetime(1601,1,1) + datetime.timedelta(microseconds=timestamp//10)
print(f" {decoded_name}: Runs={run_count}, Focus={focus_count}, Last={ts}")
else:
print(f" {decoded_name}: Runs={run_count}, Focus={focus_count}")
PYEOF
# Extract Recent Documents (MRU lists)
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/NTUSER.DAT \
-p recentdocs > /cases/case-2024-001/analysis/recentdocs.txt
# Extract typed URLs (browser)
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/NTUSER.DAT \
-p typedurls > /cases/case-2024-001/analysis/typedurls.txt
# Extract typed paths in Explorer
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/NTUSER.DAT \
-p typedpaths > /cases/case-2024-001/analysis/typedpaths.txt
手順 5:システムおよびネットワーク情報を抽出する
# Computer name and OS version from SYSTEM hive
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SYSTEM \
-p compname > /cases/case-2024-001/analysis/system_info.txt
# Network interfaces and configuration
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SYSTEM \
-p nic2 >> /cases/case-2024-001/analysis/system_info.txt
# Wireless network history
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SOFTWARE \
-p networklist > /cases/case-2024-001/analysis/network_history.txt
# Timezone configuration
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SYSTEM \
-p timezone > /cases/case-2024-001/analysis/timezone.txt
# Shutdown time
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SYSTEM \
-p shutdown > /cases/case-2024-001/analysis/shutdown.txt
# Installed software from Uninstall keys
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SOFTWARE \
-p uninstall > /cases/case-2024-001/analysis/installed_software.txt
主な概念
| 概念 | 説明 |
|---|---|
| レジストリハイブ | レジストリの一部を格納するバイナリファイル(SAM、SYSTEM、SOFTWARE、NTUSER.DAT) |
| MRU(最近使用した項目) | 最近アクセスしたファイル、コマンド、検索語を記録するリスト |
| UserAssist | プログラムの実行履歴をタイムスタンプとともに記録する、ROT13 でエンコードされたレジストリエントリ |
| ShimCache | 実行されたプログラムを記録するアプリケーション互換性キャッシュ |
| AmCache | 実行ファイルの SHA-1 ハッシュを含む詳細な実行履歴 |
| BAM/DAM | Win10+ でプログラムの実行を追跡するバックグラウンド/デスクトップアクティビティモデレーター |
| 最終書き込み時刻 | レジストリキーが最後に変更された時刻を示すタイムスタンプ |
| トランザクションログ | 正常にシャットダウンされなかった後にレジストリの状態を復元できるジャーナルファイル |
ツールとシステム
| ツール | 用途 |
|---|---|
| RegRipper | プラグインアーキテクチャによるレジストリアーティファクトの自動抽出 |
| Registry Explorer | 対話的なレジストリ分析を行う Eric Zimmerman の GUI ツール |
| python-registry | レジストリハイブをプログラムから解析するための Python ライブラリ |
| RECmd | Eric Zimmerman のコマンドラインレジストリ分析ツール |
| yarp | Python ベースの分析に使用する Yet Another Registry Parser |
| AppCompatCacheParser | ShimCache/AppCompatCache 専用のパーサー |
| AmcacheParser | AmCache.hve 専用の分析ツール |
| ShellBags Explorer | ShellBag アーティファクトの分析に特化したツール |
よくあるシナリオ
シナリオ 1:マルウェアの永続化調査 SOFTWARE と NTUSER.DAT のハイブを抽出し、すべての Run/RunOnce キーを確認して不正なエントリを探します。サービスに不審な追加がないか調べ、スケジュールされたタスクのレジストリキーを確認し、自動実行のタイムスタンプをマルウェアの実行タイムラインと関連付けます。
シナリオ 2:ユーザーアクティビティの再構成 UserAssist を分析してプログラムの実行履歴を調べ、RecentDocs でアクセスされたファイルを確認し、TypedPaths で Explorer の移動履歴を確認します。ShellBags を抽出してフォルダーへのアクセス傾向を調べ、インシデント発生時間帯の前後におけるユーザーアクティビティのタイムラインを作成します。
シナリオ 3:未承認ソフトウェアの検出 Uninstall キーを解析してインストール済みのすべてのアプリケーションを取得し、承認済みソフトウェアのベースラインと比較します。BAM/DAM を確認して、承認リストにない最近実行されたプログラムを特定し、アンインストール後の実行証拠がないか AppCompatCache を調べます。
シナリオ 4:USB を介したデータ流出の調査 SYSTEM ハイブから USBSTOR エントリを抽出して接続されたデバイスを特定し、デバイスのシリアル番号を MountedDevices と関連付けます。NTUSER.DAT の MountPoints2 を確認してユーザーによるリムーバブルメディアへのアクセスを調べ、SetupAPI ログから初回接続のタイムスタンプを確認します。
出力形式
Registry Analysis Summary:
System: DESKTOP-ABC123 (Windows 10 Pro Build 19041)
Timezone: Eastern Standard Time (UTC-5)
Last Shutdown: 2024-01-18 23:45:12 UTC
Autorun Entries:
HKLM Run: 5 entries (1 suspicious: "updater.exe" -> C:\ProgramData\svc\updater.exe)
HKCU Run: 3 entries (all legitimate)
Services: 142 entries (2 unknown: "WinDefSvc", "SysMonAgent")
User Activity (NTUSER.DAT):
UserAssist Programs: 234 entries
Recent Documents: 89 entries
Typed URLs: 45 entries
Typed Paths: 12 entries
USB Devices Connected:
- Kingston DataTraveler (Serial: 0019E06B4521) - First: 2024-01-10, Last: 2024-01-18
- WD My Passport (Serial: 575834314131) - First: 2024-01-15, Last: 2024-01-15
Installed Software: 127 applications
Suspicious Findings: 3 items flagged for review