| name | implementing-siem-correlation-rules-for-apt |
| description | 编写多事件关联规则,通过链接跨主机的 Windows 身份验证事件、进程执行遥测和网络连接日志, 检测高级持续性威胁(APT)的横向移动。使用 Splunk SPL 和 Sigma 规则格式, 在滑动时间窗口内关联事件 ID 4624、4648、4688 和 Sysmon 事件 1/3, 以发现单一事件检测无法识别的攻击序列。 |
| domain | cybersecurity |
| subdomain | security-operations |
| tags | ["implementing","siem","correlation","rules"] |
| version | 1.0 |
| author | mahipal |
| license | Apache-2.0 |
说明
- 安装依赖:
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