Communitygithub.com

Splunk 安全日誌分析

運用 Splunk Enterprise Security 與 SPL (Search Processing Language) 進行安全事件調查與威脅狩獵。

Splunk 安全日誌分析 是什麼?

這項技能專注於使用 Splunk 的 SPL (Search Processing Language) 分析安全日誌,協助調查安全事件、狩獵威脅,並建立偵測規則。它涵蓋整個工作流程:從定義調查範圍、分析驗證事件(如暴力破解、橫向移動)、追蹤程序執行鏈(使用 Sysmon)、分析網路活動(C2 信標偵測、DNS 隧道、資料外洩),到建立統一的時間線,並將調查結果轉化為持續執行的 Splunk 相關性搜尋 (Correlation Search)。此技能支援 Splunk Enterprise 與 Splunk Cloud,並假設已配置 Enterprise Security (ES) 與 Common Information Model (CIM)。提供的 SPL 查詢可直接用於 Windows 事件日誌、Sysmon、防火牆、代理伺服器與 DNS 日誌,涵蓋從初始入侵到資料外洩的完整攻擊鏈。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/analyzing-security-logs-with-splunk

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

使用 Splunk 分析安全日誌

使用時機

  • 調查需要關聯多個日誌來源的安全事件
  • 使用已知的 TTP 與 IOC 狩獵攻擊者活動
  • 為特定攻擊模式建立偵測規則
  • 從分散的日誌來源重建事件時間線
  • 分析驗證異常、橫向移動或資料外洩模式

切勿使用於即時封包層級分析;請使用 Wireshark 或 Zeek 進行完整封包擷取分析。

前提條件

  • 已安裝 Splunk Enterprise 或 Splunk Cloud 及 Enterprise Security (ES) 應用程式
  • 已攝入日誌來源:Windows 事件日誌 (透過 Splunk Universal Forwarder 或 WEF)、防火牆、代理伺服器、DNS、EDR、電子郵件閘道
  • 已設定 Splunk CIM (Common Information Model) 資料模型以標準化欄位名稱
  • 具備中級或以上的 SPL 熟練度
  • 在 Splunk 中擁有具備 search 和 accelerate_search 角色的存取權限

工作流程

步驟 1:在 Splunk 中設定調查範圍

根據事件分類資料定義搜尋參數:

| 設定初始調查範圍
index=windows OR index=firewall OR index=proxy
  earliest="2025-11-14T00:00:00" latest="2025-11-16T00:00:00"
  (host="WKSTN-042" OR src_ip="10.1.5.42" OR user="jsmith")
| stats count by index, sourcetype, host
| sort -count

此查詢可確定調查時間範圍與受影響資產中相關的日誌來源。

步驟 2:分析驗證事件

使用 Windows 安全事件日誌調查可疑的驗證模式:

| 偵測暴力破解與憑證填充
index=windows sourcetype="WinEventLog:Security" EventCode=4625
  earliest=-24h
| stats count as failed_attempts, values(src_ip) as source_ips,
  dc(src_ip) as unique_sources by TargetUserName
| where failed_attempts > 10
| sort -failed_attempts

| 偵測 Pass-the-Hash (登入類型 9 - NewCredentials)
index=windows sourcetype="WinEventLog:Security" EventCode=4624
  Logon_Type=9
| table _time, host, TargetUserName, src_ip, LogonProcessName

| 透過 RDP 偵測橫向移動
index=windows sourcetype="WinEventLog:Security" EventCode=4624
  Logon_Type=10
| stats count, values(host) as targets by TargetUserName, src_ip
| where count > 3
| sort -count

步驟 3:追蹤程序執行

使用 Sysmon 日誌重建程序執行鏈:

| 含父程序鏈的程序建立 (Sysmon 事件 ID 1)
index=sysmon EventCode=1 host="WKSTN-042"
  earliest="2025-11-15T14:00:00" latest="2025-11-15T15:00:00"
| table _time, ParentImage, ParentCommandLine, Image, CommandLine, User, Hashes
| sort _time

| 偵測可疑的 PowerShell 執行
index=sysmon EventCode=1 Image="*\\powershell.exe"
  (CommandLine="*-enc*" OR CommandLine="*-encodedcommand*"
   OR CommandLine="*downloadstring*" OR CommandLine="*iex*")
| table _time, host, User, ParentImage, CommandLine
| sort _time

| 偵測 LSASS 憑證傾印
index=sysmon EventCode=10 TargetImage="*\\lsass.exe"
  GrantedAccess=0x1010
| table _time, host, SourceImage, SourceUser, GrantedAccess

步驟 4:分析網路活動

將網路日誌與端點事件關聯:

| 偵測 C2 信標模式
index=proxy OR index=firewall dest_ip="185.220.101.42"
| timechart span=1m count by src_ip
| where count > 0

| 偵測 DNS 隧道 (對單一網域的高查詢量)
index=dns
| rex field=query "(?<subdomain>[^\.]+)\.(?<domain>[^\.]+\.[^\.]+)$"
| stats count, avg(len(query)) as avg_query_len by domain, src_ip
| where count > 500 AND avg_query_len > 40
| sort -count

| 偵測大型資料傳輸 (潛在的外洩)
index=proxy action=allowed
| stats sum(bytes_out) as total_bytes by src_ip, dest_ip, dest_host
| eval total_MB=round(total_bytes/1024/1024,2)
| where total_MB > 100
| sort -total_MB

步驟 5:建立事件時間線

在所有日誌來源中重建統一的時間線:

| 統一的事件時間線
index=windows OR index=sysmon OR index=proxy OR index=firewall
  (host="WKSTN-042" OR src_ip="10.1.5.42" OR user="jsmith")
  earliest="2025-11-15T14:00:00" latest="2025-11-15T16:00:00"
| eval event_summary=case(
    sourcetype=="WinEventLog:Security" AND EventCode==4624, "登入: ".TargetUserName." 來自 ".src_ip,
    sourcetype=="WinEventLog:Security" AND EventCode==4625, "登入失敗: ".TargetUserName,
    sourcetype=="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" AND EventCode==1,
      "程序: ".Image." 由 ".User,
    sourcetype=="proxy", "網頁: ".http_method." ".url,
    1==1, sourcetype.": ".EventCode)
| table _time, sourcetype, host, event_summary
| sort _time

步驟 6:建立偵測規則

將調查結果轉化為持續執行的 Splunk 相關性搜尋:

| 相關性搜尋:由 Office 應用程式啟動的 PowerShell
index=sysmon EventCode=1
  Image="*\\powershell.exe"
  (ParentImage="*\\winword.exe" OR ParentImage="*\\excel.exe"
   OR ParentImage="*\\outlook.exe")
| eval severity="high"
| eval mitre_technique="T1059.001"
| collect index=notable_events

關鍵概念

術語定義
SPL (Search Processing Language)Splunk 的查詢語言,用於搜尋、過濾、轉換和視覺化機器資料
CIM (Common Information Model)Splunk 的欄位標準化模型,將供應商特定的欄位名稱對應到通用名稱,以便進行跨來源查詢
Notable EventSplunk Enterprise Security 中根據相關性搜尋比對而被標記供分析師審查的事件
資料模型 (Data Model)Splunk 中索引資料的結構化表示,支援加速搜尋和基於樞紐的分析
SourcetypeSplunk 中的分類標籤,定義特定日誌類型的格式和解析規則
相關性搜尋 (Correlation Search)在 Splunk 中排程的持續執行搜尋,當條件符合時產生 Notable 事件
時間圖表 (Timechart)SPL 指令,用於建立時間序列視覺化以識別模式、異常和趨勢

工具與系統

  • Splunk Enterprise Security (ES):進階 SIEM 應用程式,提供相關性搜尋、基於風險的警報和調查工作檯
  • Splunk SOAR:與 Splunk ES 整合的協調平台,用於自動化回應劇本
  • Sysmon:Microsoft 系統監控工具,提供詳細的程序、網路和檔案變更遙測資料,並攝入 Splunk
  • Splunk Attack Analyzer:自動化威脅分析工具,可引爆可疑檔案和 URL,並將結果饋送至 Splunk
  • BOSS of the SOC (BOTS):SANS/Splunk 培訓資料集,用於練習事件調查的 SPL 查詢

常見情境

情境:調查導致帳號劫持的憑證填充攻擊

背景:安全維運中心收到警報,顯示一個帳號在 30 分鐘內從地理上分散的 IP 位址成功登入多次。

方法:

  1. 查詢受影響帳號的事件 ID 4624,以繪製所有登入來源和時間
  2. 使用 Splunk 查閱表格將登入 IP 與威脅情报饋送進行關聯
  3. 檢查代理伺服器日誌中從驗證會話產生的可疑活動
  4. 搜尋來自身分遭洩露帳號的橫向移動 (對其他主機的事件 ID 4624 類型 3)
  5. 建立時間線,顯示憑證填充嘗試、成功登入和入侵後活動
  6. 建立相關性搜尋以偵測其他帳號的類似模式

陷阱:

  • 僅搜尋過去 24 小時,而憑證填充可能發生在數週內
  • 未檢查 VPN 日誌,這些日誌可能顯示同一帳號從不可能的旅行距離進行驗證
  • 未能標準化跨不同時區日誌來源的時間戳記

輸出格式

SPLUNK 調查報告
============================
事件編號:       INC-2025-1547
分析師:         [姓名]
調查期間:       2025-11-14 00:00 UTC - 2025-11-16 00:00 UTC

搜尋範圍
索引:           windows, sysmon, proxy, firewall, dns
主機:           WKSTN-042, SRV-FILE01
使用者:         jsmith, svc-backup
來源 IP:        10.1.5.42, 10.1.10.15

主要發現
1. [時間戳記] - 透過網路釣魚初始入侵 (Sysmon 事件 1)
2. [時間戳記] - 建立 C2 (代理伺服器日誌,偵測到信標模式)
3. [時間戳記] - 憑證遭竊 (Sysmon 事件 10,LSASS 存取)
4. [時間戳記] - 橫向移動至 SRV-FILE01 (事件 4624 類型 3)
5. [時間戳記] - 資料分階段與外洩 (代理伺服器 bytes_out 異常)

使用的 SPL 查詢
[含說明的關鍵查詢編號清單]

已識別的偵測缺口
- SRV-FILE01 上未部署 Sysmon (盲區)
- 代理伺服器日誌缺少對 C2 網域的 SSL 檢查
- 未啟用 PowerShell ScriptBlock 記錄

建議的偵測規則
1. Office 啟動 PowerShell 的相關性搜尋
2. LSASS 存取模式的閾值警示
3. 信標間隔網路流量的行為規則

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,

相關技能