Log Analysis & SIEM Integration について
Log Analysis & SIEM Integrationは、ログ調査や検知コンテンツの作成を行うセキュリティ分析者向けのClaudeスキルです。複数のSIEM向けクエリ、移植可能なSigmaルール、異常検知、複数イベントの相関を扱います。
主な機能
- 01Windows、Linux、アプリケーションログの分析
- 02Splunk、Elastic、Sentinelのクエリ作成
- 03Sigmaルールの作成と変換
- 04異常とログソースの欠落の特定
- 05複数イベントの相関検知設計
活用シーン
- 01ログイン失敗や不審なプロセスイベントの調査
- 02SIEM向け攻撃検知クエリの作成
- 03検知ロジックをSigmaルールに変換
- 04ログソースの停止や行動の逸脱を監視
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ masriyan/ claude-code-cybersecurity-skill --skill log-analysis-&-siem-integrationインストール後、Claude Code で/log-analysis-&-siem-integrationを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
examples/example_usage.mdscripts/log_parser.pyanomaly_detector.py詳細
ログ分析と SIEM 統合
目的
すべての主要プラットフォームにわたるセキュリティログ分析を Claude が支援できるようにします。ユーザーが提供したログサンプルを Claude が直接解析・分析し、任意のプラットフォーム向けに SIEM クエリを作成し、移植可能な検知のための Sigma ルールを作成し、相関ルールを開発し、ログデータ内の異常なパターンを特定します。
有効化のトリガー
以下についてユーザーが質問した場合に、このスキルが有効になります。
- Windows イベントログ、Linux syslog、またはアプリケーションログの解析
- Splunk SPL、Elastic KQL/EQL、QRadar AQL、または Sentinel KQL クエリの作成
- プラットフォームに依存しない検知のための Sigma ルールの作成
- ログデータ内の異常や攻撃パターンの検知
- 複雑な攻撃シナリオ向けの SIEM 相関ルールの作成
- SIEM プラットフォーム間のクエリ変換
- ログソースの健全性監視とギャップ分析
- ログ内のラテラルムーブメント、権限昇格、または永続化の検知
- EVTX 分析または Windows 監査ログのレビュー
前提条件
pip install pandas pyyaml python-dateutil
プラットフォームツール:
Splunk— Splunk Web、SPL、SOARElastic Stack— Kibana、KQL、EQLMicrosoft Sentinel— KQL、WorkbooksIBM QRadar— AQL、ルールSigma— プラットフォームに依存しないルール形式python-evtx— Windows を使わずに Windows .evtx ファイルを解析
主な機能
1. ログの解析と分析
ユーザーがログを貼り付けるか、ログファイルを提供した場合:
Claude はログを直接読み取り、セキュリティ関連イベントを抽出して分析します。
Windows イベントログ — 重要なイベント ID:
| イベント ID | ログ | 説明 |
|---|---|---|
| 4624 | Security | ログオン成功 — ログオンの種類が 3(ネットワーク)の場合は注目します |
| 4625 | Security | ログオン失敗 — ブルートフォース攻撃に備えて送信元 IP を追跡します |
| 4648 | Security | 明示的な資格情報を使用したログオン(RunAs) |
| 4688 | Security | 新しいプロセスが作成されました — CommandLine 監査を有効にする必要があります |
| 4698 | Security | スケジュールされたタスクが作成されました |
| 4702 | Security | スケジュールされたタスクが更新されました |
| 4720 | Security | ユーザーアカウントが作成されました |
| 4728/4732 | Security | セキュリティグループまたはローカルグループにメンバーが追加されました |
| 4768/4769 | Security | Kerberos TGT/TGS が要求されました |
| 4776 | Security | NTLM 認証 |
| 4946 | Security | Windows ファイアウォールのルールが追加されました |
| 5140 | Security | ネットワーク共有にアクセスしました |
| 5145 | Security | ネットワーク共有上のファイルにアクセスしました |
| 7045 | System | 新しいサービスがインストールされました |
| 1102 | Security | 監査ログが消去されました |
| 4103/4104 | PowerShell | PowerShell モジュール/スクリプトブロックのログ記録 |
Linux ログ分析 — 主なパターン:
# Failed SSH logins
grep "Failed password" /var/log/auth.log | awk '{print $1,$2,$3,$11}' | sort | uniq -c | sort -rn
# Successful logins after failures (brute force success)
grep "Accepted password\|Accepted publickey" /var/log/auth.log
# Sudo usage
grep "sudo:" /var/log/auth.log | grep -v "session"
# Cron job execution
grep CRON /var/log/syslog
# New user creation
grep "useradd\|usermod" /var/log/auth.log
# Privilege escalation
grep "su\b" /var/log/auth.log
ログ解析スクリプト:
python scripts/log_parser.py --input /var/log/auth.log --format json --output parsed.json
python scripts/log_parser.py --input events.evtx --normalize ecs --output normalized.json
2. SIEM クエリライブラリ
ユーザーが検知クエリの作成を求めた場合:
Splunk SPL — 攻撃パターンのクエリ
// Brute force attack detection
index=windows EventCode=4625
| bin _time span=5m
| stats count as FailedLogins, values(Account_Name) as Accounts by src_ip, _time
| where FailedLogins > 20
| sort -FailedLogins
// Pass-the-Hash detection (Logon Type 3 with NTLM)
index=windows EventCode=4624 Logon_Type=3 Authentication_Package=NTLM
| where NOT (Account_Name="ANONYMOUS LOGON" OR Account_Name="*$")
| stats count by Account_Name, Workstation_Name, src_ip
| where count > 1
// Lateral movement via PsExec / admin shares
index=windows EventCode=5145
| where (ShareName="\\\\*\\ADMIN$" OR ShareName="\\\\*\\C$")
AND RelativeTargetName="*PSEXESVC*"
| table _time, SubjectUserName, IpAddress, ShareName
// PowerShell encoded command execution
index=windows (source="WinEventLog:Microsoft-Windows-PowerShell/Operational" EventCode=4104)
OR (EventCode=4688 CommandLine="*powershell*")
| search CommandLine IN ("*-EncodedCommand*", "*-enc *", "*-e *", "*-nop*",
"*DownloadString*", "*IEX*", "*Invoke-Expression*")
| table _time, ComputerName, User, CommandLine
// Scheduled task creation for persistence
index=windows EventCode=4698
| rex field=TaskContent "<Command>(?P<command>[^<]+)</Command>"
| where NOT match(command, "(?i)\\\\windows\\\\|\\\\microsoft\\\\|\\\\system32\\\\")
| table _time, ComputerName, SubjectUserName, TaskName, command
// LSASS memory access (credential dumping)
index=sysmon EventCode=10 TargetImage="*lsass.exe"
| where NOT (SourceImage IN
("C:\\Windows\\System32\\*", "C:\\Windows\\SysWOW64\\*",
"C:\\Program Files\\*", "C:\\Program Files (x86)\\*"))
| table _time, SourceImage, GrantedAccess, CallTrace
// DCSync detection
index=windows EventCode=4662
(ObjectType="*domainDNS*" OR ObjectType="*19195a5b-6da0-11d0-afd3-00c04fd930c9*")
(Properties="*Replicating Directory Changes All*" OR Properties="*1131f6ad*")
| where NOT match(SubjectUserName, "(?i)^.*\$$")
| table _time, SubjectUserName, SubjectDomainName, Properties
// Kerberoasting detection
index=windows EventCode=4769 Ticket_Encryption_Type=0x17
| where NOT (Account_Name="*$" OR Service_Name IN ("krbtgt", "kadmin/changepw"))
| stats count by Account_Name, Client_Address, Service_Name
| where count > 3
Microsoft Sentinel KQL — クエリ
// Impossible Travel (logins from geographically impossible locations)
let TimeDelta = 2h;
SigninLogs
| where ResultType == 0 // Successful logins only
| where TimeGenerated > ago(7d)
| project UserPrincipalName, Location, TimeGenerated, IPAddress
| sort by UserPrincipalName asc, TimeGenerated asc
| serialize
| extend PreviousLogin = prev(TimeGenerated), PreviousLocation = prev(Location)
| where UserPrincipalName == prev(UserPrincipalName)
| extend TimeDiff = TimeGenerated - PreviousLogin
| where TimeDiff < TimeDelta and Location != PreviousLocation
| project UserPrincipalName, Location, PreviousLocation, TimeDiff, IPAddress
// Azure AD privilege escalation
AuditLogs
| where OperationName in ("Add member to role", "Add eligible member to role")
| extend TargetUser = tostring(TargetResources[0].userPrincipalName)
| extend RoleAdded = tostring(TargetResources[0].displayName)
| where RoleAdded in ("Global Administrator", "Security Administrator",
"Exchange Administrator", "SharePoint Administrator")
| project TimeGenerated, TargetUser, RoleAdded,
InitiatedBy=tostring(InitiatedBy.user.userPrincipalName)
// Suspicious PowerShell activity
SecurityEvent
| where EventID == 4104
| where TimeGenerated > ago(24h)
| where ScriptBlockText has_any("IEX", "DownloadString", "EncodedCommand",
"WebClient", "Invoke-Expression", "bypass", "-nop")
| project TimeGenerated, Computer, Account, ScriptBlockText
| extend RiskScore = case(
ScriptBlockText has "IEX" and ScriptBlockText has "DownloadString", 10,
ScriptBlockText has "EncodedCommand", 7,
ScriptBlockText has "bypass", 5, 3)
| where RiskScore >= 5
| order by RiskScore desc
Elastic EQL — シーケンス検知
// Detect fileless malware execution chain
sequence by host.name with maxspan=5m
[process where event.type == "start" and
process.name in ("outlook.exe", "winword.exe", "excel.exe")]
[process where event.type == "start" and
process.name in ("powershell.exe", "cmd.exe", "wscript.exe", "cscript.exe")]
[network where network.direction == "egress" and
not network.destination.ip in ("127.0.0.0/8", "10.0.0.0/8", "192.168.0.0/16")]
// Ransomware detection: mass file extension changes + shadow copy deletion
sequence by host.name with maxspan=30m
[file where event.type == "creation" and
file.extension in ("locked", "encrypted", "crypted", "enc", "readme")]
[file where event.type == "creation" and
file.name in ("README.txt", "DECRYPT.txt", "HOW_TO_DECRYPT.txt")]
[process where event.type == "start" and
process.command_line : "* delete shadows *"]
3. 異常検知の方法論
ユーザーがログデータ内の異常検知を求めた場合:
統計的異常検知:
# Claude's approach to analyzing log data for anomalies:
import pandas as pd
from datetime import timedelta
# 1. Volume anomalies
# Calculate rolling average, flag if current > mean + 3*stddev
# 2. Time-based anomalies (off-hours activity)
# Business hours: Mon-Fri 08:00-18:00 local time
# Flag: admin activities on weekends, logins at 03:00 UTC
# 3. Never-before-seen entities
# - New admin account created
# - First-time login from country
# - New process never seen before
# - New domain in DNS queries
# 4. Impossible travel
# Calculate geographic distance / time delta
# Flag if impossible to travel physically in the time window
python scripts/anomaly_detector.py --logs parsed.json --baseline baseline.json --output anomalies.json
異常のカテゴリ:
| カテゴリ | 指標 |
|---|---|
| ボリュームの急増 | 5 分間のイベント発生率が通常の 10 倍 |
| 時間外のアクティビティ | 現地時間 03:00 の管理者アクセス |
| 未知の地域 | 過去に履歴のない国からのログイン |
| 新しいプロセス | バイナリの初回実行 |
| 大量のデータ転送 | このユーザー/システムのベースラインの 10 倍を超えるアップロード |
| 無応答のログソース | 30 分以上イベントを受信していない |
| 認証パターン | 管理者以外のワークステーションからのログオンの種類 3 |
4. Sigma ルールの開発
ユーザーが Sigma ルールの作成を求めた場合:
title: Credential Dumping via Procdump
id: e5eb5a27-4a98-4c34-8b39-1fbe552d2aa4
status: stable
description: Detects the use of ProcDump to dump LSASS memory for credential theft
author: SOC Analyst
date: 2025/05/28
references:
- https://attack.mitre.org/techniques/T1003/001/
- https://docs.microsoft.com/en-us/sysinternals/downloads/procdump
tags:
- attack.credential_access
- attack.t1003.001
logsource:
category: process_creation
product: windows
detection:
selection_tool:
Image|endswith:
- '\procdump.exe'
- '\procdump64.exe'
selection_lsass:
CommandLine|contains:
- 'lsass'
- '-ma 4' # PID 4 = System, sometimes used
selection_flags:
CommandLine|contains|all:
- '-accepteula'
- '-ma'
condition: selection_tool and (selection_lsass or selection_flags)
falsepositives:
- Legitimate use by administrators for debugging (rare, should be investigated)
level: high
Sigma ルールの SIEM プラットフォーム向け変換:
# Install sigma-cli
pip install sigma-cli
# Convert to Splunk SPL
sigma convert -t splunk -p splunk_windows sigma_rule.yml
# Convert to Elastic KQL
sigma convert -t elasticsearch -p ecs_windows sigma_rule.yml
# Convert to Microsoft Sentinel KQL
sigma convert -t kusto sigma_rule.yml
5. 相関ルールの開発
マルチイベント検出の相関ルール作成をユーザーから求められた場合:
## Correlation Rule: Brute Force → Successful Login → Lateral Movement
**Trigger:**
Event 1: 4625 (Failed Login) × 20+ in 5 minutes (same source IP)
THEN Event 2: 4624 (Successful Login) from same source IP within 10 minutes
THEN Event 3: 5145 (Admin Share Access) from same host within 30 minutes
**Logic:**
Step 1: 5 分間隔で送信元 IP ごとにログイン失敗を集計します
Step 2: 件数が 20 を超えた場合 → IP を「ブルートフォースの送信元」としてマークします
Step 3: 同じ IP から 10 分以内にログイン成功がないか監視します
Step 4: ログインに成功した場合 → 重大度を HIGH に引き上げます
Step 5: ログインに成功したホストからのラテラルムーブメントを監視します
Step 6: 3 つすべてのイベントが確認された場合、インシデントとして宣言します
**Splunk Correlation (corr_rule.conf):**
```spl
index=windows EventCode=4625
| bin _time span=5m
| stats count by src_ip, _time
| where count > 20
| join src_ip [
search index=windows EventCode=4624
| bin _time span=10m
| stats count by src_ip, _time, Account_Name, Workstation_Name
]
| table _time, src_ip, Account_Name, Workstation_Name, count
抑制と重複排除:
- 最初に発報した後、同じ送信元 IP からの同じ相関アラートを 1 時間抑制します
- 既知の脆弱性スキャナーを除外します(スキャナーの IP 範囲を例外リストに追加します)
- 文書化されたスケジュール済みタスクを持つサービスアカウントを除外します
ログソースの健全性監視
ユーザーからログソースの健全性について尋ねられた場合:
// Splunk: Detect silent log sources (no events in 30 minutes)
| tstats count WHERE index=* BY host, sourcetype, _time span=30m
| where _time > relative_time(now(), "-30m@m")
| stats max(_time) as last_seen by host, sourcetype
| where last_seen < relative_time(now(), "-30m@m")
| eval lag = round((now() - last_seen) / 60, 1)
| table host, sourcetype, last_seen, lag
| sort -lag
スクリプトリファレンス
log_parser.py
python scripts/log_parser.py --input /var/log/auth.log --format json --output parsed.json
python scripts/log_parser.py --input events.evtx --normalize ecs --output normalized.json
anomaly_detector.py
python scripts/anomaly_detector.py --logs parsed.json --baseline baseline.json --output anomalies.json
スキルの連携
| 条件 | 関連スキル |
|---|---|
| 異常を検出 → SOC にエスカレーション | → スキル 11(CSOC Automation) |
| 異常がハントの手掛かり | → スキル 06(Threat Hunting) |
| IR 向けにログからタイムラインを作成 | → スキル 07(Incident Response) |
| 調査結果から検出ルールを作成 | → スキル 15(Blue Team Defense) |
参考資料
- Splunk SPL リファレンス
- Elastic EQL ドキュメント
- Microsoft Sentinel KQL
- Sigma Rules HQ リポジトリ
- Windows セキュリティ監査ポリシー
- OCSF スキーマ
- SANS Windows ロギングチートシート
v3.0 の強化点(2026 年の更新)
正規化され、テスト可能な検出コンテンツ:
- OCSF / ECS 正規化 — ソースを Open Cybersecurity Schema Framework(または Elastic Common Schema)にマッピングし、複数のフィードで同じ検出ルールを機能させます。各ルールでスキーマを明示します。
- Sigma 相関ルール — 単一イベントの照合だけでなく、マルチイベント検出(例:ブルートフォース → 成功、低速かつ長期的な情報流出)に Sigma の相関拡張(count/temporal/value-count)を使用します。
- Detection-as-code CI — すべてのルールに正例/負例のサンプルイベントを使った単体テストを用意します。デプロイ前に、CI でルールのリンティングとバックエンドごとの変換(
sigma convert)を行います。 - UEBA とアイデンティティ分析 — ユーザー/ホストごとの行動のベースラインを作成し、固定のしきい値ではなく、逸脱(新たな管理者アクション、異常なデータ量、あり得ない移動)をアラートします。
- プラットフォームの最新性 — Splunk(
tstats/データモデル)、Microsoft Sentinel(KQL、ASIM 関数)、Elastic(ES|QL/EQL)の例を掲載します。
精度に関するルール: 各ルールに、データソースとスキーマ、誤検知の条件、ATT&CK マッピング、およびテスト済みのサンプルイベントを記載します。