mcpField
A
analyzing-security-logs-with-splunk

analyzing-security-logs-with-splunk

github.com/mukul975安全35.2k270 次安装8 周前更新
代码仓库

关于 analyzing-security-logs-with-splunk

面向安全分析人员的 Splunk 技能,用于跨日志源调查事件和搜寻威胁活动。提供关联分析、重建时间线及将发现转化为检测搜索的工作流程。

主要功能

  1. 01跨索引界定调查范围
  2. 02分析身份验证异常
  3. 03追踪进程执行
  4. 04关联网络与终端日志
  5. 05重建事件时间线
  6. 06创建关联搜索

适用场景

  1. 01调查疑似账户失陷
  2. 02搜寻对手行为与指标
  3. 03重建跨日志源的活动
  4. 04将调查发现转为持续检测

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill analyzing-security-logs-with-splunk

安装后在 Claude Code 中输入/analyzing-security-logs-with-splunk确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

LICENSE
references/
api-reference.md
scripts/
agent.py

详细介绍

使用 Splunk 分析安全日志

何时使用

  • 调查需要跨多个日志源关联的安全事件
  • 使用已知 TTP 和 IOC 搜寻攻击者活动
  • 针对特定攻击模式构建检测规则
  • 从不同日志源重建事件时间线
  • 分析身份验证异常、横向移动或数据外泄模式

不要用于实时数据包级分析;全数据包捕获分析请使用 Wireshark 或 Zeek。

前提条件

  • 已安装 Enterprise Security (ES) 应用的 Splunk Enterprise 或 Splunk Cloud
  • 已接入日志源:Windows 事件日志(通过 Splunk Universal Forwarder 或 WEF)、防火墙、代理、DNS、EDR、电子邮件网关
  • 已配置 Splunk CIM(公共信息模型)数据模型,以规范化字段名称
  • SPL 熟练度达到中级或以上
  • 在 Splunk 中具有 search 和 accelerate_search 能力的基于角色的访问权限

工作流

步骤 1:在 Splunk 中界定调查范围

根据事件分类数据定义搜索参数:

| Set initial investigation scope
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 安全事件日志调查可疑的身份验证模式:

| Detect brute force and credential stuffing
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

| Detect pass-the-hash (Logon Type 9 - NewCredentials)
index=windows sourcetype="WinEventLog:Security" EventCode=4624
  Logon_Type=9
| table _time, host, TargetUserName, src_ip, LogonProcessName

| Detect lateral movement via 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 日志重建进程执行链:

| Process creation with parent chain (Sysmon Event 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

| Detect suspicious PowerShell execution
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

| Detect LSASS credential dumping
index=sysmon EventCode=10 TargetImage="*\\lsass.exe"
  GrantedAccess=0x1010
| table _time, host, SourceImage, SourceUser, GrantedAccess
步骤 4:分析网络活动

将网络日志与终端事件关联:

| Detect C2 beaconing pattern
index=proxy OR index=firewall dest_ip="185.220.101.42"
| timechart span=1m count by src_ip
| where count > 0

| Detect DNS tunneling (high query volume to single domain)
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

| Detect large data transfers (potential exfiltration)
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:构建事件时间线

跨所有日志源重建统一时间线:

| Unified incident timeline
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, "Logon: ".TargetUserName." from ".src_ip,
    sourcetype=="WinEventLog:Security" AND EventCode==4625, "Failed logon: ".TargetUserName,
    sourcetype=="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" AND EventCode==1,
      "Process: ".Image." by ".User,
    sourcetype=="proxy", "Web: ".http_method." ".url,
    1==1, sourcetype.": ".EventCode)
| table _time, sourcetype, host, event_summary
| sort _time
步骤 6:创建检测规则

将调查发现转化为持久的 Splunk 关联搜索:

| Correlation search: PowerShell spawned by Office applications
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: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 INVESTIGATION REPORT
============================
Incident:        INC-2025-1547
Analyst:         [Name]
Investigation Period: 2025-11-14 00:00 UTC - 2025-11-16 00:00 UTC

SEARCH SCOPE
Indexes:         windows, sysmon, proxy, firewall, dns
Hosts:           WKSTN-042, SRV-FILE01
Users:           jsmith, svc-backup
Source IPs:      10.1.5.42, 10.1.10.15

KEY FINDINGS
1. [timestamp] - Initial compromise via phishing (Sysmon Event 1)
2. [timestamp] - C2 established (proxy logs, beacon pattern detected)
3. [timestamp] - Credential theft (Sysmon Event 10, LSASS access)
4. [timestamp] - Lateral movement to SRV-FILE01 (Event 4624 Type 3)
5. [timestamp] - Data staging and exfiltration (proxy bytes_out anomaly)

SPL QUERIES USED
[numbered list of key queries with descriptions]

DETECTION GAPS IDENTIFIED
- No Sysmon deployed on SRV-FILE01 (blind spot)
- Proxy logs missing SSL inspection for C2 domain
- PowerShell ScriptBlock logging not enabled

RECOMMENDED DETECTIONS
1. Correlation search for Office-spawned PowerShell
2. Threshold alert for LSASS access patterns
3. Behavioral rule for beacon-interval network traffic

评论

支持 Markdown