sahilsinghi/sigma-detection-rules
GitHub: sahilsinghi/sigma-detection-rules
一套涵盖 31 条 MITRE ATT&CK 战术的 Sigma 检测规则库,通过 pySigma 自动编译并验证 Splunk、Sentinel、Elastic 和 Wazuh 四种 SIEM 平台的查询规则。
Stars: 0 | Forks: 0
# Sigma 检测规则





## 覆盖范围概览
| 战术 | 规则 | 技术 |
|--------|------:|------------|
| Initial Access | 2 | T1566.001, T1078 |
| Execution | 4 | T1059.001, T1059.003, T1059.004, T1053.005 |
| Persistence | 4 | T1547.001, T1136.001, T1543.003, T1505.003 |
| Privilege Escalation | 2 | T1548.002, T1055.001 |
| Defense Evasion | 3 | T1562.001, T1070.001, T1036.005 |
| Credential Access | 4 | T1003.001, T1110.003, T1552.001, T1558.003 |
| Discovery | 3 | T1087.001, T1082, T1018 |
| Lateral Movement | 3 | T1021.002, T1021.001, T1570 |
| Collection | 2 | T1005, T1560.001 |
| Command and Control | 2 | T1071.001, T1048.003 |
| Exfiltration | 1 | T1041 |
| Impact | 1 | T1486 |
| **总计** | **31** | **32 个子技术** |
## 仓库结构
```
sigma-detection-rules/
│
├── rules/ # All 31 Sigma rules, organized by tactic
│ ├── initial-access/
│ │ ├── T1566.001_phishing_malicious_attachment/
│ │ │ ├── rule.yml # Sigma YAML rule (the source of truth)
│ │ │ ├── sample-log.evtx.xml # Representative Windows event log fragment
│ │ │ ├── README.md # Technique background, FPs, response actions
│ │ │ └── compiled/
│ │ │ ├── splunk.spl # Splunk SPL search
│ │ │ ├── sentinel.kql # Microsoft Sentinel KQL query
│ │ │ ├── elastic.json # Elastic Lucene DSL query
│ │ │ └── wazuh.xml # Wazuh rule XML
│ │ └── T1078_valid_accounts_abuse/
│ ├── execution/
│ ├── persistence/
│ ├── privilege-escalation/
│ ├── defense-evasion/
│ ├── credential-access/
│ ├── discovery/
│ ├── lateral-movement/
│ ├── collection/
│ ├── command-and-control/
│ ├── exfiltration/
│ └── impact/
│
├── scripts/
│ ├── convert.py # Sigma converter: YAML → SPL/KQL/Elastic/Wazuh
│ └── export_navigator.py # ATT&CK Navigator layer generator
│
├── tests/
│ └── attack-command-to-alert/ # 10 attack-to-alert triplet documents
│ ├── T1059.001_powershell_encoded_command.md
│ ├── T1003.001_lsass_memory_dump.md
│ ├── T1562.001_disable_windows_defender.md
│ ├── T1547.001_registry_run_keys.md
│ ├── T1110.003_password_spraying.md
│ ├── T1486_data_encrypted_for_impact.md
│ ├── T1558.003_kerberoasting.md
│ ├── T1566.001_phishing_malicious_attachment.md
│ ├── T1021.002_smb_admin_share_access.md
│ └── T1070.001_clear_windows_event_logs.md
│
├── navigator/
│ └── sigma-rules-coverage.json # ATT&CK Navigator layer (import at attack.mitre.org)
│
├── examples/
│ └── how-to-import-each-siem.md # Step-by-step SIEM import guide
│
├── .github/
│ └── workflows/
│ └── ci.yml # GitHub Actions CI pipeline
│
├── requirements.txt # Python dependencies (pySigma + backends)
└── LICENSE # MIT License
```
## 快速开始 — 转换规则
**前置条件:** Python 3.9+ 及 pySigma 工具栈。
```
# Clone 仓库
git clone https://github.com/sahilsinghi/sigma-detection-rules.git
cd sigma-detection-rules
# 安装依赖
pip install -r requirements.txt
# 将单个 rule 转换为所有 4 个 backends
python scripts/convert.py rules/execution/T1059.001_powershell_encoded_command/rule.yml
# 转换仓库中的每个 rule
python scripts/convert.py rules/
# 编译后的输出将写入每个 rule 的 compiled/ 目录:
# rules/execution/T1059.001_powershell_encoded_command/compiled/splunk.spl
# rules/execution/T1059.001_powershell_encoded_command/compiled/sentinel.kql
# rules/execution/T1059.001_powershell_encoded_command/compiled/elastic.json
# rules/execution/T1059.001_powershell_encoded_command/compiled/wazuh.xml
```
**T1059.001 的输出示例 (Splunk SPL):**
```
Image="*\powershell.exe" CommandLine IN ("*-EncodedCommand*", "*-encodedcommand*", "* -enc *", "* -EC *", "*/enc *", "*/EncodedCommand*", "*-e *")
```
**T1059.001 的输出示例 (Sentinel KQL):**
```
DeviceProcessEvents
| where FolderPath endswith "\\powershell.exe"
| where ProcessCommandLine has_any ("-EncodedCommand", "-encodedcommand", " -enc ", " -EC ", "/enc ", "/EncodedCommand", "-e ")
```
## 将规则导入您的 SIEM
请参阅 **[examples/how-to-import-each-siem.md](examples/how-to-import-each-siem.md)** 获取所有四个受支持平台的完整分步说明。
| SIEM | 格式 | 导入方法 |
|------|--------|---------------|
| Splunk Enterprise Security | SPL (`compiled/splunk.spl`) | Saved Search / ES Correlation Search / REST API |
| Microsoft Sentinel | KQL (`compiled/sentinel.kql`) | Analytics Rules UI / ARM Template / API |
| Elastic Security | Lucene DSL (`compiled/elastic.json`) | Detection Rules UI / Fleet / Elastic API |
| Wazuh | XML (`compiled/wazuh.xml`) | `local_rules.xml` / `wazuh-logtest` 验证 |
## ATT&CK Navigator 覆盖范围
文件 `navigator/sigma-rules-coverage.json` 是一个预构建的 ATT&CK Navigator 层级文件,用于在 MITRE ATT&CK 矩阵上可视化所有 31 条规则。
**查看方式:**
1. 访问 [https://mitre-attack.github.io/attack-navigator/](https://mitre-attack.github.io/attack-navigator/)
2. 点击 **Open Existing Layer** → **Upload from local**
3. 选择 `navigator/sigma-rules-coverage.json`
该层级文件使用 ATT&CK v14,根据检测置信度级别(`critical` = 红色,`high` = 橙色,`medium` = 黄色)对技术进行着色,并在矩阵单元格中显示规则 ID。它会在每次 CI 运行时通过 `scripts/export_navigator.py` 自动重新生成。
## CI Pipeline
每次推送到 `main` 或 `master` 分支且涉及 `rules/`、`scripts/` 或 `requirements.txt` 的更改时,都会触发 GitHub Actions CI 工作流 (`.github/workflows/ci.yml`),该工作流会:
1. 安装 pySigma 和所有 SIEM 后端(固定版本记录在 `requirements.txt` 中)
2. 运行 `python scripts/convert.py rules/` 将每条规则编译为所有 4 种后端格式
3. 验证每条规则是否都存在所有 4 个已编译的输出文件(如果缺失任何一个则失败)
4. 验证每条规则的 YAML schema(检查必填字段:`title`、`id`、`status`、`description`、`tags`、`logsource`、`detection`、`level`)
5. 通过 `scripts/export_navigator.py` 重新生成 ATT&CK Navigator 层级文件
CI 构建失败意味着规则的 Sigma 语法无效,或者缺少已编译的输出。**任何规则都必须通过所有 4 种后端的测试才能发布。**
## 误报理念
本仓库中的每条规则都在 Sigma YAML 中包含了 `falsepositives:` 部分,并在每个规则专属的 `README.md` 中提供了专门的调优部分。其指导原则是:
**允许列表优于阈值。** 通过提高检测阈值(例如“仅在超过 100 个事件时告警”)来减少误报会延迟检测,并可能使攻击者在阈值触发前完成其目标。相反,每条规则都经过调优,以识别真正恶意的最小可能行为集合,并将已知的正常进程添加到明确的允许列表中。
**记录而非抑制。** 当合法工具(SCCM、Ansible、备份软件)触发规则时,正确的做法是添加一个带有解释注释的命名例外——而不是全局削弱规则。这保留了针对不使用允许列表工具的攻击者的检测有效性。
**级别反映置信度,而非严重性。** 每条规则中的 `level` 字段反映了匹配为恶意的可能性(信噪比),而不是技术的破坏性。`critical` 级别的规则(如 LSASS 内存转储)的误报率几乎为零;`medium` 级别的规则(如注册表 Run 键写入)具有已知的良性触发条件(如软件安装程序),必须根据每个环境的具体情况进行调优。
## Wazuh 后端说明
截至 2024 年中期,尚无官方的 pySigma Wazuh 后端。每个规则 `compiled/` 目录中的 `wazuh.xml` 文件是由 `scripts/convert.py` 内部的自定义模板引擎生成的。该引擎:
- 提取 Sigma 检测逻辑(字段名称、值、条件)
- 通过 `_sigma_field_to_wazuh()` 函数将 Sigma 字段名称映射为 Wazuh ECS 风格的解码字段
- 生成有效的 Wazuh 规则 XML,包含 PCRE2 字段匹配器、MITRE ID 标签以及映射了严重性的 `level` 属性
**字段映射表**(来自 `scripts/convert.py`):
| Sigma 字段 | Wazuh 字段 |
|-------------|-------------|
| `CommandLine` | `win.eventdata.commandLine` |
| `Image` | `win.eventdata.image` |
| `ParentImage` | `win.eventdata.parentImage` |
| `TargetObject` | `win.eventdata.targetObject` |
| `TargetFilename` | `win.eventdata.targetFilename` |
| `EventID` | `win.system.eventID` |
| `SourceImage` | `win.eventdata.sourceImage` |
| `TargetImage` | `win.eventdata.targetImage` |
生成的 Wazuh 规则使用 100000–109999 范围内的 ID(专为本地自定义规则保留),并要求使用 `decoded_as: json`(Wazuh 的 Sysmon/Windows 解码器)。有关部署说明,请参阅导入指南。
## 完成定义
- [x] 涵盖 12 种 MITRE ATT&CK 战术的 31 条 Sigma 规则
- [x] 每条规则都包含:Sigma YAML + 示例日志 (`.evtx.xml`) + 已编译的 SPL/KQL/Elastic/Wazuh + 规则专属 README
- [x] Python 转换器 (`scripts/convert.py`) — 一条命令即可生成所有 4 种后端输出
- [x] GitHub Actions CI — 如果任何规则编译失败或任何已编译输出缺失,构建即告失败
- [x] ATT&CK Navigator 层级 JSON (`navigator/sigma-rules-coverage.json`) — 在 CI 上自动重新生成
- [x] 10 个攻击命令到告警的测试三元组 (`tests/attack-command-to-alert/`)
- [x] 所有 4 个平台的 SIEM 导入指南 (`examples/how-to-import-each-siem.md`)
- [x] MIT 许可证
## 简历要点
## 作者
Sahil Singhi | [github.com/sahilsinghi](https://github.com/sahilsinghi)
标签:HTTP工具, OpenCanary, Sigma规则, 安全, 安全助手, 安全运营, 扫描框架, 无线安全, 目标导入, 超时处理, 逆向工具