说明
- 安装依赖:
pip install requests pyyaml sigma-cli - 连接到 Splunk REST API,定义跨主机链接多种事件类型的关联搜索。
- 构建 Sigma YAML 规则,表达横向移动模式的多步骤检测逻辑:
- RDP 登录(4624 LogonType=10)后在同一目标上安装服务(7045),时间窗口 15 分钟
- 哈希传递(Pass-the-Hash):NTLM 登录(4624 LogonType=3)后创建管理工具进程(4688)
- PsExec 方式:命名管道创建(Sysmon 17/18)与远程服务创建(7045)关联
- 使用
sigma-cli convert将 Sigma 规则转换为 Splunk SPL。 - 通过 REST API 将关联搜索部署到 Splunk ES。
- 运行 Agent 生成并安装关联规则,然后审计现有规则的覆盖缺口。
python scripts/agent.py --splunk-url https://localhost:8089 --username admin --password changeme --output correlation_report.json
示例
检测 RDP 横向移动链
index=wineventlog (EventCode=4624 Logon_Type=10) OR (EventCode=7045)
| transaction Computer maxspan=15m startswith=(EventCode=4624) endswith=(EventCode=7045)
| where eventcount >= 2
| table _time Computer Account_Name ServiceName
PsExec 横向移动的 Sigma 规则
title: PsExec 横向移动检测
logsource:
product: windows
service: sysmon
detection:
pipe_created:
EventID: 17
PipeName|startswith: '\PSEXESVC'
service_installed:
EventID: 7045
ServiceFileName|contains: 'PSEXESVC'
timeframe: 5m
condition: pipe_created | near service_installed
level: high