extracting-windows-event-logs-artifacts について
インシデント対応、脅威ハンティング、フォレンジック調査で Windows の EVTX ログを分析するセキュリティスキルです。Sigma検知、タイムライン生成、イベント解析で不審な活動を調べます。
主な機能
- 01EVTXファイルの収集
- 02ChainsawによるSigma検知
- 03Hayabusaによるタイムライン生成
- 04Pythonでのイベント解析
- 05攻撃パターンの調査
活用シーン
- 01ラテラルムーブメントの探索
- 02権限昇格の調査
- 03PowerShell活動の分析
- 04ランサムウェア事案の再構成
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ mukul975/ anthropic-cybersecurity-skills --skill extracting-windows-event-logs-artifactsインストール後、Claude Code で/extracting-windows-event-logs-artifactsを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
LICENSEreferences/api-reference.mdscripts/agent.py詳細
Windows イベントログのアーティファクトを抽出する
使用するタイミング
- Windows システムのイベントログ分析を通じてセキュリティインシデントを調査するとき
- ラテラルムーブメント、権限昇格、永続化の仕組みを検出するとき
- Windows イベントログデータ全体を対象に脅威ハンティングを行うとき
- 認証イベントやアクセスイベントの確認が必要なコンプライアンス監査を実施するとき
- Windows システムのアクティビティからフォレンジックタイムラインを作成するとき
前提条件
- フォレンジックイメージまたは稼働中のシステムから取得した Windows イベントログファイル(EVTX 形式)
- 解析と検出に使用する Chainsaw、Hayabusa、または EvtxECmd
- 自動脅威検出用の Sigma ルール
- 重要な Windows イベント ID に関する知識
- カスタム解析用の python-evtx または evtx ライブラリを備えた Python
- (該当する場合)稼働中のシステム分析用の PowerShell
ワークフロー
ステップ 1:Windows イベントログファイルを収集する
# Extract EVTX files from forensic image
mount -o ro,loop,offset=$((2048*512)) /cases/case-2024-001/images/evidence.dd /mnt/evidence
mkdir -p /cases/case-2024-001/evtx/
cp /mnt/evidence/Windows/System32/winevt/Logs/*.evtx /cases/case-2024-001/evtx/
# Key event logs to prioritize
# Security.evtx - Authentication, authorization, audit events
# System.evtx - System services, drivers, hardware events
# Application.evtx - Application errors and events
# Microsoft-Windows-Sysmon%4Operational.evtx - Detailed process/network monitoring
# Microsoft-Windows-PowerShell%4Operational.evtx - PowerShell activity
# Microsoft-Windows-TerminalServices-LocalSessionManager%4Operational.evtx - RDP sessions
# Microsoft-Windows-TaskScheduler%4Operational.evtx - Scheduled tasks
# Microsoft-Windows-WinRM%4Operational.evtx - Windows Remote Management
# Microsoft-Windows-Bits-Client%4Operational.evtx - BITS transfers
# Microsoft-Windows-Windows Defender%4Operational.evtx - AV detections
# List available log files and sizes
ls -lhS /cases/case-2024-001/evtx/ | head -20
# Hash for integrity
sha256sum /cases/case-2024-001/evtx/*.evtx > /cases/case-2024-001/evtx/evtx_hashes.txt
ステップ 2:Chainsaw を実行して Sigma ベースの検出を行う
# Install Chainsaw
wget https://github.com/WithSecureLabs/chainsaw/releases/latest/download/chainsaw_all_platforms+rules.zip
unzip chainsaw_all_platforms+rules.zip -d /opt/chainsaw
# Run Chainsaw with bundled Sigma rules
/opt/chainsaw/chainsaw hunt /cases/case-2024-001/evtx/ \
-s /opt/chainsaw/sigma/rules/ \
--mapping /opt/chainsaw/mappings/sigma-event-logs-all.yml \
--output /cases/case-2024-001/analysis/chainsaw_results.txt
# Run with CSV output for easier analysis
/opt/chainsaw/chainsaw hunt /cases/case-2024-001/evtx/ \
-s /opt/chainsaw/sigma/rules/ \
--mapping /opt/chainsaw/mappings/sigma-event-logs-all.yml \
--csv \
--output /cases/case-2024-001/analysis/chainsaw_results/
# Run with JSON output
/opt/chainsaw/chainsaw hunt /cases/case-2024-001/evtx/ \
-s /opt/chainsaw/sigma/rules/ \
--mapping /opt/chainsaw/mappings/sigma-event-logs-all.yml \
--json \
--output /cases/case-2024-001/analysis/chainsaw_results.json
# Search for specific keywords
/opt/chainsaw/chainsaw search /cases/case-2024-001/evtx/ \
-s "mimikatz" --json
# Search for specific event IDs
/opt/chainsaw/chainsaw search /cases/case-2024-001/evtx/ \
-e 4688 --json | head -100
ステップ 3:Hayabusa を実行して高速にタイムラインを生成する
# Install Hayabusa
wget https://github.com/Yamato-Security/hayabusa/releases/latest/download/hayabusa-linux-x64-musl.zip
unzip hayabusa-linux-x64-musl.zip -d /opt/hayabusa
# Generate CSV timeline with all detection rules
/opt/hayabusa/hayabusa csv-timeline \
-d /cases/case-2024-001/evtx/ \
-o /cases/case-2024-001/analysis/hayabusa_timeline.csv \
-p verbose
# Generate JSON timeline
/opt/hayabusa/hayabusa json-timeline \
-d /cases/case-2024-001/evtx/ \
-o /cases/case-2024-001/analysis/hayabusa_timeline.json
# Run with only critical and high severity detections
/opt/hayabusa/hayabusa csv-timeline \
-d /cases/case-2024-001/evtx/ \
-o /cases/case-2024-001/analysis/hayabusa_critical.csv \
-p verbose \
--min-level critical
# Generate detection summary (metrics)
/opt/hayabusa/hayabusa metrics \
-d /cases/case-2024-001/evtx/ \
-o /cases/case-2024-001/analysis/hayabusa_metrics.csv
# Logon summary
/opt/hayabusa/hayabusa logon-summary \
-d /cases/case-2024-001/evtx/ \
-o /cases/case-2024-001/analysis/logon_summary.csv
ステップ 4:特定の重要なイベント ID を解析する
# Extract authentication events with python-evtx
pip install evtx
python3 << 'PYEOF'
import json
from evtx import PyEvtxParser
parser = PyEvtxParser("/cases/case-2024-001/evtx/Security.evtx")
# Critical Event IDs mapping
critical_events = {
'4624': 'Successful Logon',
'4625': 'Failed Logon',
'4634': 'Logoff',
'4648': 'Explicit Credential Logon',
'4672': 'Special Privileges Assigned',
'4688': 'Process Created',
'4689': 'Process Exited',
'4697': 'Service Installed',
'4698': 'Scheduled Task Created',
'4720': 'User Account Created',
'4724': 'Password Reset Attempted',
'4728': 'Member Added to Global Group',
'4732': 'Member Added to Local Group',
'4756': 'Member Added to Universal Group',
'1102': 'Audit Log Cleared',
'4688': 'New Process Created'
}
results = {eid: [] for eid in critical_events}
for record in parser.records_json():
data = json.loads(record['data'])
event_id = str(data['Event']['System']['EventID'])
if event_id in critical_events:
event_data = data['Event'].get('EventData', {})
results[event_id].append({
'timestamp': data['Event']['System']['TimeCreated']['#attributes']['SystemTime'],
'event_id': event_id,
'description': critical_events[event_id],
'data': event_data
})
# Print summary
for eid, events in results.items():
if events:
print(f"\n[{eid}] {critical_events[eid]}: {len(events)} events")
for e in events[:3]:
print(f" {e['timestamp']}: {json.dumps(e['data'], default=str)[:200]}")
if len(events) > 3:
print(f" ... and {len(events)-3} more")
# Save full results
with open('/cases/case-2024-001/analysis/critical_events.json', 'w') as f:
json.dump(results, f, indent=2, default=str)
PYEOF
ステップ 5:特定の攻撃パターンを検出する
# Detect Pass-the-Hash (Logon Type 9 with NTLM)
python3 << 'PYEOF'
import json
from evtx import PyEvtxParser
parser = PyEvtxParser("/cases/case-2024-001/evtx/Security.evtx")
print("=== PASS-THE-HASH INDICATORS ===")
print("Looking for: Event 4624, Logon Type 9, NTLM authentication\n")
for record in parser.records_json():
data = json.loads(record['data'])
event_id = str(data['Event']['System']['EventID'])
if event_id == '4624':
event_data = data['Event'].get('EventData', {})
logon_type = str(event_data.get('LogonType', ''))
auth_package = str(event_data.get('AuthenticationPackageName', ''))
logon_process = str(event_data.get('LogonProcessName', ''))
# Pass-the-Hash indicators
if logon_type == '9' and 'NTLM' in auth_package:
timestamp = data['Event']['System']['TimeCreated']['#attributes']['SystemTime']
target = event_data.get('TargetUserName', 'Unknown')
source_ip = event_data.get('IpAddress', 'N/A')
print(f" [{timestamp}] PtH: User={target}, IP={source_ip}, Auth={auth_package}")
# Network logon with NTLM (lateral movement)
if logon_type == '3' and 'NTLM' in auth_package:
timestamp = data['Event']['System']['TimeCreated']['#attributes']['SystemTime']
target = event_data.get('TargetUserName', 'Unknown')
source_ip = event_data.get('IpAddress', 'N/A')
workstation = event_data.get('WorkstationName', 'N/A')
print(f" [{timestamp}] Network NTLM: User={target}, IP={source_ip}, WS={workstation}")
PYEOF
# Detect log clearing / anti-forensics
python3 << 'PYEOF'
import json
from evtx import PyEvtxParser
for log_file in ['Security.evtx', 'System.evtx']:
path = f"/cases/case-2024-001/evtx/{log_file}"
try:
parser = PyEvtxParser(path)
for record in parser.records_json():
data = json.loads(record['data'])
event_id = str(data['Event']['System']['EventID'])
if event_id in ('1102', '104'): # Security log cleared, System log cleared
timestamp = data['Event']['System']['TimeCreated']['#attributes']['SystemTime']
print(f"LOG CLEARED: [{timestamp}] EventID {event_id} in {log_file}")
except Exception as e:
print(f"Error parsing {log_file}: {e}")
PYEOF
主な概念
| 概念 | 説明 |
|---|---|
| EVTX 形式 | Vista/Server 2008 で導入された、バイナリ XML ベースの Windows イベントログ形式 |
| イベント ID | 特定のイベント種別を識別する数値(例:4624 = ログオン成功) |
| ログオンの種類 | 認証方式の分類(2=対話型、3=ネットワーク、10=RDP) |
| Sigma ルール | 特定の SIEM/ログクエリに対応付けられる汎用的な検出シグネチャ |
| Sysmon | 詳細なプロセスイベントとネットワークイベントを提供する Microsoft のシステム監視ドライバー |
| 監査ポリシー | Windows が記録するイベントを制御する GPO 設定 |
| イベント転送(WEF) | イベントログを一元的に収集する Windows の仕組み |
| EVTX チャネル | イベントカテゴリやアプリケーションごとに分かれた個別のログファイル |
ツールとシステム
| ツール | 用途 |
|---|---|
| Chainsaw | Sigma ベースの EVTX 分析および脅威ハンティングツール |
| Hayabusa | Windows イベントログから高速にフォレンジックタイムラインを生成するツール |
| EvtxECmd | Eric Zimmerman によるコマンドライン EVTX パーサー。CSV/JSON 出力に対応 |
| python-evtx | EVTX ファイルを解析する Python ライブラリ |
| LogParser | Windows ログ用の Microsoft 製 SQL ライクなクエリエンジン |
| Event Log Explorer | EVTX ファイルの閲覧と分析に使用する GUI ツール |
| KAPE | イベントログを含む自動トリアージ収集ツール |
| Velociraptor | EVTX の収集とハンティング用アーティファクトに対応したエンドポイントエージェント |
よくあるシナリオ
シナリオ 1:ラテラルムーブメントの検出 ログオンの種類が 3(ネットワーク)および 10(RDP)のイベント 4624 をフィルターし、通常とは異なる送信元と宛先の組み合わせを特定します。パス・ザ・ハッシュを示すイベント 4648(明示的な資格情報)を確認し、対象システムでプロセス作成イベント(4688)と関連付けます。
シナリオ 2:権限昇格の検出 予期しないユーザーに対するイベント 4672(特別な権限の割り当て)を検索します。ユーザーを管理者グループに追加するイベント 4728/4732(グループメンバーシップの変更)を確認し、新たなシステムレベルのアクセスを示すイベント 4697(サービスのインストール)を調べ、4720(アカウント作成)と関連付けます。
シナリオ 3:PowerShell 攻撃の検出 PowerShell Operational ログでスクリプトブロックのログ記録(イベント 4104)を分析します。イベント 4688(コマンドラインを含むプロセス作成)内のエンコードされたコマンドを検索し、AMSI のバイパス試行を検出するとともに、ダウンロードクレードルや既知の攻撃ツールの実行を特定します。
シナリオ 4:ランサムウェアインシデントの再構成 初期アクセス(外部 IP からの 4624)を起点にタイムラインを作成し、グループメンバーシップの変更を通じて権限昇格を追跡します。永続化のためのサービスインストールを特定し、暗号化実行ファイルのプロセス作成イベントを探し、System ログでボリュームシャドウコピーの削除を検出します。
出力形式
Windows Event Log Analysis Summary:
System: DC01.corp.local (Windows Server 2019)
Log Files Analyzed: 15 EVTX files
Total Events: 2,456,789
Analysis Period: 2024-01-10 to 2024-01-20
Chainsaw Detections:
Critical: 12 (Mimikatz usage, PsExec, log clearing)
High: 34 (Network NTLM logons, encoded PowerShell)
Medium: 89 (Unusual service installations, scheduled tasks)
Low: 234 (Informational)
Hayabusa Timeline:
Total Alerts: 369
Unique Rules Triggered: 45
Top Rules:
- Suspicious NTLM Authentication (34 hits)
- PowerShell Download Cradle (12 hits)
- Service Installation Suspicious Path (8 hits)
Critical Findings:
2024-01-15 14:32 - RDP brute force (234 failed, 1 success from 203.0.113.45)
2024-01-15 14:45 - Admin account created (svcbackup) - Event 4720
2024-01-16 02:30 - PsExec service installed on DC01 - Event 4697
2024-01-18 03:00 - Security log cleared - Event 1102
Reports:
Chainsaw: /analysis/chainsaw_results/
Hayabusa: /analysis/hayabusa_timeline.csv
Critical Events: /analysis/critical_events.json