Communitygithub.com

使用 Splunk 分析安全日志

利用 Splunk Enterprise Security 和 SPL(搜索处理语言)进行安全事件调查与威胁狩猎。

使用 Splunk 分析安全日志 是什么?

该技能引导安全分析师借助 Splunk Enterprise Security(ES)和 Splunk 搜索处理语言(SPL)开展系统化的安全事件调查和威胁狩猎。它覆盖了从事件范围界定、身份认证异常检测、进程执行链重建、网络活动关联分析,到统一时间线还原和检测规则创建的全流程。技能中提供了大量可直接运行的 SPL 查询示例,涵盖 Windows 安全事件日志(Event ID 4624/4625)、Sysmon(事件 ID 1/10)、代理、防火墙、DNS 等常见日志源。该技能适用于 Splunk Enterprise 和 Splunk Cloud(需安装 ES 应用并已配置 CIM 数据模型),要求分析师具备中高级 SPL 水平。通过遵循此工作流,分析师能够高效定位横向移动、凭据窃取、C2 通信及数据外泄等可疑活动,并生成结构化的详实调查报告。

兼容平台~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 分析安全日志 是做什么的?

何时使用

  • 调查需要跨多个日志源进行关联分析的安全事件
  • 使用已知的 TTPs 和 IOCs 进行威胁狩猎
  • 针对特定攻击模式构建检测规则
  • 从分散的日志源重建事件时间线
  • 分析身份认证异常、横向移动或数据外泄模式

不要用于实时数据包级分析;应使用 Wireshark 或 Zeek 进行全流量分析。

先决条件

  • Splunk Enterprise 或 Splunk Cloud(已安装 Enterprise Security (ES) 应用程序)
  • 已摄入的日志源:Windows 事件日志(通过 Splunk Universal Forwarder 或 WEF)、防火墙、代理、DNS、EDR、邮件网关
  • 已配置 Splunk CIM(通用信息模型)数据模型以标准化字段名称
  • 具备中级或更高级别的 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

| 检测传递哈希(登录类型 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", "Web: ".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(搜索处理语言)Splunk 的查询语言,用于搜索、过滤、转换和可视化机器数据
CIM(通用信息模型)Splunk 的字段标准化标准,将供应商特定的字段名称映射为通用名称,以支持跨源查询
可关注事件Splunk Enterprise Security 中,根据关联搜索匹配而标记为需要分析师审查的事件
数据模型Splunk 中索引数据的一种结构化表示,支持加速搜索和基于透视的分析
数据源类型Splunk 中的分类标签,定义特定日志类型的格式和解析规则
关联搜索Splunk 中计划执行的搜索,持续运行并在满足条件时生成可关注事件
时间图表SPL 命令,用于创建时间序列可视化,以识别模式、异常和趋势

工具与系统

  • Splunk Enterprise Security (ES):高级 SIEM 应用程序,提供关联搜索、基于风险告警和调查工作台
  • Splunk SOAR:与 Splunk ES 集成的编排平台,用于自动化响应剧本
  • Sysmon:微软系统监控工具,提供详细的进程、网络和文件更改遥测数据,并摄入到 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,

相关技能