memory-forensics について
インシデント対応担当者やマルウェア分析者向けのメモリフォレンジックのスキルです。RAM ダンプの取得と、Volatility 3 や YARA を使ったプロセス、ネットワーク活動、コード注入、認証情報などの調査を扱います。
主な機能
- 01稼働中システムと仮想マシンのメモリ取得
- 02Volatility 3 による分析手順
- 03プロセスとネットワーク痕跡の調査
- 04コード注入とルートキットの検出パターン
- 05認証情報と文字列の抽出
- 06YARA によるメモリスキャン
活用シーン
- 01インシデント対応でメモリを調査
- 02RAM ダンプからマルウェアの痕跡を一次分析
- 03不審なプロセス注入やルートキットを調査
- 04メモリから認証情報や開いたファイルの痕跡を復元
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ wshobson/ agents --skill memory-forensicsインストール後、Claude Code で/memory-forensicsを入力して読み込まれたか確認します。
同梱ファイルreferences/details.md
詳細
メモリフォレンジック
インシデントレスポンスとマルウェア分析のために、メモリダンプからアーティファクトを取得、分析、抽出するための包括的な手法です。
このスキルを使用する場面
- インシデントレスポンスや侵害調査の際にメモリ分析を実施する場合
- RAM キャプチャからマルウェアのアーティファクト(プロセス、注入されたコード、ネットワーク接続)を抽出する場合
- シャットダウン前に、稼働中の Windows/Linux/macOS システムから揮発性メモリを取得する場合
- Volatility 3 / Rekall を使用してメモリダンプをトリアージする場合
- プロセスメモリから認証情報、ブラウザセッション、開いているファイルを復元する場合
メモリの取得
ライブ取得ツール
Windows
# WinPmem (Recommended)
winpmem_mini_x64.exe memory.raw
# DumpIt
DumpIt.exe
# Belkasoft RAM Capturer
# GUI-based, outputs raw format
# Magnet RAM Capture
# GUI-based, outputs raw format
Linux
# LiME (Linux Memory Extractor)
sudo insmod lime.ko "path=/tmp/memory.lime format=lime"
# /dev/mem (limited, requires permissions)
sudo dd if=/dev/mem of=memory.raw bs=1M
# /proc/kcore (ELF format)
sudo cp /proc/kcore memory.elf
macOS
# osxpmem
sudo ./osxpmem -o memory.raw
# MacQuisition (commercial)
仮想マシンのメモリ
# VMware: .vmem file is raw memory
cp vm.vmem memory.raw
# VirtualBox: Use debug console
vboxmanage debugvm "VMName" dumpvmcore --filename memory.elf
# QEMU
virsh dump <domain> memory.raw --memory-only
# Hyper-V
# Checkpoint contains memory state
詳細セクション: Volatility 3 フレームワーク
元々この SKILL.md 内にあった 2680 バイトのセクションです。Codex のスキル本文 8 KB 上限に収めるため、references/details.md に移動しました。
分析ワークフロー
マルウェア分析ワークフロー
# 1. Initial process survey
vol -f memory.raw windows.pstree > processes.txt
vol -f memory.raw windows.pslist > pslist.txt
# 2. Network connections
vol -f memory.raw windows.netscan > network.txt
# 3. Detect injection
vol -f memory.raw windows.malfind > malfind.txt
# 4. Analyze suspicious processes
vol -f memory.raw windows.dlllist --pid <PID>
vol -f memory.raw windows.handles --pid <PID>
# 5. Dump suspicious executables
vol -f memory.raw windows.pslist --pid <PID> --dump
# 6. Extract strings from dumps
strings -a pid.<PID>.exe > strings.txt
# 7. YARA scanning
vol -f memory.raw windows.yarascan --yara-rules malware.yar
インシデントレスポンスワークフロー
# 1. Timeline of events
vol -f memory.raw windows.timeliner > timeline.csv
# 2. User activity
vol -f memory.raw windows.cmdline
vol -f memory.raw windows.consoles
# 3. Persistence mechanisms
vol -f memory.raw windows.registry.printkey \
--key "Software\Microsoft\Windows\CurrentVersion\Run"
# 4. Services
vol -f memory.raw windows.svcscan
# 5. Scheduled tasks
vol -f memory.raw windows.scheduled_tasks
# 6. Recent files
vol -f memory.raw windows.filescan | grep -i "recent"
データ構造
Windows のプロセス構造
// EPROCESS (Executive Process)
typedef struct _EPROCESS {
KPROCESS Pcb; // Kernel process block
EX_PUSH_LOCK ProcessLock;
LARGE_INTEGER CreateTime;
LARGE_INTEGER ExitTime;
// ...
LIST_ENTRY ActiveProcessLinks; // Doubly-linked list
ULONG_PTR UniqueProcessId; // PID
// ...
PEB* Peb; // Process Environment Block
// ...
} EPROCESS;
// PEB (Process Environment Block)
typedef struct _PEB {
BOOLEAN InheritedAddressSpace;
BOOLEAN ReadImageFileExecOptions;
BOOLEAN BeingDebugged; // Anti-debug check
// ...
PVOID ImageBaseAddress; // Base address of executable
PPEB_LDR_DATA Ldr; // Loader data (DLL list)
PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
// ...
} PEB;
VAD(仮想アドレス記述子)
typedef struct _MMVAD {
MMVAD_SHORT Core;
union {
ULONG LongFlags;
MMVAD_FLAGS VadFlags;
} u;
// ...
PVOID FirstPrototypePte;
PVOID LastContiguousPte;
// ...
PFILE_OBJECT FileObject;
} MMVAD;
// Memory protection flags
#define PAGE_EXECUTE 0x10
#define PAGE_EXECUTE_READ 0x20
#define PAGE_EXECUTE_READWRITE 0x40
#define PAGE_EXECUTE_WRITECOPY 0x80
検出パターン
プロセスインジェクションの指標
# Malfind indicators
# - PAGE_EXECUTE_READWRITE protection (suspicious)
# - MZ header in non-image VAD region
# - Shellcode patterns at allocation start
# Common injection techniques
# 1. Classic DLL Injection
# - VirtualAllocEx + WriteProcessMemory + CreateRemoteThread
# 2. Process Hollowing
# - CreateProcess (SUSPENDED) + NtUnmapViewOfSection + WriteProcessMemory
# 3. APC Injection
# - QueueUserAPC targeting alertable threads
# 4. Thread Execution Hijacking
# - SuspendThread + SetThreadContext + ResumeThread
ルートキットの検出
# Compare process lists
vol -f memory.raw windows.pslist > pslist.txt
vol -f memory.raw windows.psscan > psscan.txt
diff pslist.txt psscan.txt # Hidden processes
# Check for DKOM (Direct Kernel Object Manipulation)
vol -f memory.raw windows.callbacks
# Detect hooked functions
vol -f memory.raw windows.ssdt # System Service Descriptor Table
# Driver analysis
vol -f memory.raw windows.driverscan
vol -f memory.raw windows.driverirp
認証情報の抽出
# Dump hashes (requires hivelist first)
vol -f memory.raw windows.hashdump
# LSA secrets
vol -f memory.raw windows.lsadump
# Cached domain credentials
vol -f memory.raw windows.cachedump
# Mimikatz-style extraction
# Requires specific plugins/tools
YARA 統合
メモリ用 YARA ルールの作成
rule Suspicious_Injection
{
meta:
description = "Detects common injection shellcode"
strings:
// Common shellcode patterns
$mz = { 4D 5A }
$shellcode1 = { 55 8B EC 83 EC } // Function prologue
$api_hash = { 68 ?? ?? ?? ?? 68 ?? ?? ?? ?? E8 } // Push hash, call
condition:
$mz at 0 or any of ($shellcode*)
}
rule Cobalt_Strike_Beacon
{
meta:
description = "Detects Cobalt Strike beacon in memory"
strings:
$config = { 00 01 00 01 00 02 }
$sleep = "sleeptime"
$beacon = "%s (admin)" wide
condition:
2 of them
}
メモリのスキャン
# Scan all process memory
vol -f memory.raw windows.yarascan --yara-rules rules.yar
# Scan specific process
vol -f memory.raw windows.yarascan --yara-rules rules.yar --pid 1234
# Scan kernel memory
vol -f memory.raw windows.yarascan --yara-rules rules.yar --kernel
文字列分析
文字列の抽出
# Basic string extraction
strings -a memory.raw > all_strings.txt
# Unicode strings
strings -el memory.raw >> all_strings.txt
# Targeted extraction from process dump
vol -f memory.raw windows.memmap --pid 1234 --dump
strings -a pid.1234.dmp > process_strings.txt
# Pattern matching
grep -E "(https?://|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})" all_strings.txt
難読化された文字列に対する FLOSS
# FLOSS extracts obfuscated strings
floss malware.exe > floss_output.txt
# From memory dump
floss pid.1234.dmp
ベストプラクティス
取得のベストプラクティス
- フットプリントを最小化する: 軽量な取得ツールを使用します
- すべてを記録する: 取得の時刻、ツール、ハッシュを記録します
- 完全性を検証する: キャプチャ直後にメモリダンプのハッシュを取得します
- 保管の連鎖: 適切なフォレンジックの取り扱いを維持します
分析のベストプラクティス
- 広く始める: 深掘りする前に全体像を把握します
- 相互参照する: 同じデータに対して複数のプラグインを使用します
- タイムラインの相関: メモリの検出結果をディスクやネットワークと関連付けます
- 検出結果を記録する: 詳細なメモとスクリーンショットを保持します
- 結果を検証する: 複数の方法で検出結果を確認します
よくある落とし穴
- 古いデータ: メモリは揮発性であるため、速やかに分析します
- 不完全なダンプ: ダンプサイズが想定される RAM と一致するか確認します
- シンボルの問題: OS バージョンに合ったシンボルファイルを確保します
- スミア: 取得中にメモリが変化する可能性があります
- 暗号化: メモリ内の一部のデータは暗号化されている場合があります
コメント
Markdown 対応