Khadinxc/TerraSigma
GitHub: Khadinxc/TerraSigma
将 Sigma 检测规则自动转换为 Terraform 格式,实现 Microsoft Sentinel 检测规则的基础设施即代码管理和自动化部署。
Stars: 2 | Forks: 0


# TerraSigma - 面向云原生 SIEM Microsoft Sentinel 的现代检测工程 - 自动更新
__转换为 Terraform 的 Sigma 规则,用于部署到 Microsoft Sentinel。__
本仓库自动执行 Sigma → KQL → Terraform 再回到 Sentinel YAML 的转换,使得使用基础设施即代码(Infrastructure-as-Code)管理检测规则变得简单。
关键点:
- 转换器现在默认保留原始的 Sigma/TF 源文件夹布局(`source`)。
- 您也可以选择使用 `--output-structure` 按主要的 MITRE 战术(`tactics`)对输出进行分组。
- 实体映射已更新为使用有效的 Microsoft Sentinel 标识符(Account、Host、Process、File、IP、Registry、URL 等)。
## 快速入门
1. 克隆 Sigma2KQL 规则仓库:
```
git clone https://github.com/Khadinxc/Sigma2KQL.git
```
2. 克隆本仓库:
```
git clone https://github.com/Khadinxc/TerraSigma.git
cd TerraSigma
```
3. 创建并激活 Python 虚拟环境:
Windows (PowerShell):
```
python -m venv .venv
.\.venv\Scripts\Activate.ps1
```
Linux/macOS:
```
python -m venv .venv
source .venv/bin/activate
```
4. 安装依赖项:
```
pip install -r requirements.txt
```
## kql_to_terraform (KQL/Sigma → Terraform)
从您通过 `Sigma2KQL` 获取的 KQL 规则生成 Terraform 规则。
默认(在 `./TF` 下保留源文件夹结构):
```
python kql_to_terraform.py --kql-dir ./KQL --output-dir ./TF --schemas ./schemas.json
```
改为按主要的 MITRE 战术分组输出(旧版行为):
```
python kql_to_terraform.py --kql-dir ./KQL --output-dir ./TF --schemas ./schemas.json --output-structure tactics
```
注意:
- 脚本尝试将字段映射到有效的 Microsoft Sentinel 标识符。只要表架构提供合适的字段,就会添加 `Account` 和 `Host` 映射。对于包含 IP 列的表(例如 `DeviceNetworkEvents`),会出现 `IP` 映射。
- 文件哈希映射到 `FileHash` 标识符;`File` 实体标识符为 `Name` 和 `Directory`。
## terraform_to_yaml (Terraform → Sentinel YAML)
将 Terraform 规则资源转换为可用于导入的 Azure Sentinel YAML。
默认(在 `./YAML` 下保留 TF 文件夹布局):
```
python terraform_to_yaml.py --tf-dir ./TF --output-dir ./YAML
```
改为按主要的 MITRE 战术分组 YAML 文件:
```
python terraform_to_yaml.py --tf-dir ./TF --output-dir ./YAML --output-structure tactics
```
标签:AMSI绕过, Azure, Cloudflare, Cloud-Native, Detection Engineering, DevSecOps, EC2, ECS, IaC, KQL, Kusto Query Language, Microsoft Sentinel, MITRE ATT&CK, Python, Python 实现, Sigma Rule, Sigma规则, Terraform, 上游代理, 威胁检测, 安全信息与事件管理, 安全运营中心, 实体映射, 微软Sentinel, 搜索引擎爬取, 无后门, 特权提升, 目标导入, 网络安全, 网络映射, 自动化部署, 规则转换, 逆向工具, 隐私保护