Reinhard1268/threat-hunting-platform

GitHub: Reinhard1268/threat-hunting-platform

基于Sysmon、Wazuh和Elasticsearch构建的生产级威胁狩猎平台,提供端到端的检测规则、狩猎查询和攻击模拟验证能力。

Stars: 1 | Forks: 0

# 04 - 威胁狩猎平台 ### Sysmon + Wazuh EDR 威胁狩猎平台 ![Platform](https://img.shields.io/badge/Platform-Kali%20Linux-blue) ![Sysmon](https://img.shields.io/badge/Sysmon-15.x-red) ![Wazuh](https://img.shields.io/badge/Wazuh-4.x-orange) ![Elastic](https://img.shields.io/badge/Elastic-8.x-yellow) ![Python](https://img.shields.io/badge/Python-3.10%2B-green) ![Status](https://img.shields.io/badge/Status-Complete-brightgreen) ## 概述 一个基于 Sysmon 15.x、Wazuh 4.x 和 Elasticsearch 8.x 构建的生产级**威胁狩猎平台**。该平台提供主动的、基于假设的威胁狩猎能力,覆盖 LOLBAS 滥用、进程注入、持久化机制和网络异常——包含完整的模拟、检测验证和自动化报告功能。 ## 架构 ``` Windows Endpoint └── Sysmon 15.x (advanced config) └── Wazuh Agent └── Wazuh Manager (Kali Linux) ├── Custom Decoders (Sysmon + Win Security) ├── Custom Rules (100200–100306) └── Elasticsearch 8.x └── Kibana 8.x ├── Threat Hunting Dashboard ├── 15 KQL/EQL Hunt Queries └── Index Patterns ``` ## 功能特性 | 功能 | 描述 | |---------|-------------| | **Sysmon 配置** | 基线、高级(全覆盖)、最小(低资源) | | **自定义解码器** | 所有 Sysmon Event ID + Windows Security 事件 | | **检测规则** | 15 条威胁狩猎规则 + 7 条关联规则 | | **狩猎查询** | 跨 4 个类别的 15 条 KQL/EQL 查询 | | **Kibana 仪表板** | 7 面板实时威胁狩猎仪表板 | | **攻击模拟** | 覆盖完整杀伤链的 5 个模拟脚本 | | **自动化狩猎** | `run-hunt.py` 运行所有查询并生成报告 | | **日志解析器** | `parse-logs.py` 将 Sysmon 日志导出为 JSON/CSV/MD | | **部署脚本** | 用于 Sysmon 部署/更新/验证的 PowerShell 脚本 | ## 检测覆盖范围 ### LOLBAS (T1218) | 二进制文件 | 规则 | MITRE | |--------|------|-------| | certutil | 100202 | T1105 | | regsvr32 | 100201 | T1218.010 | | rundll32 | 100200 | T1218.011 | | mshta | 100205 | T1218.005 | | bitsadmin | 100202 | T1197 | ### 进程注入 (T1055) | 技术 | 规则 | MITRE | |-----------|------|-------| | CreateRemoteThread | 100204 | T1055.003 | | LSASS 访问 | 100203, 100215 | T1003.001 | | Reflective DLL | 100204 | T1055.001 | ### 持久化 (T1547/T1053/T1543) | 技术 | 规则 | MITRE | |-----------|------|-------| | 注册表 Run Keys | Sysmon EID 12/13 | T1547.001 | | 计划任务 | 100209 | T1053.005 | | 新服务 | 100210 | T1543.003 | | 启动文件夹 | Sysmon EID 11 | T1547.001 | ### 网络 (T1071) | 技术 | 规则 | MITRE | |-----------|------|-------| | 脚本引擎 C2 | 100211 | T1071.001 | | 可疑 DNS TLD | 100213 | T1568.002 | | Office 宏 + 网络 | 100303 | T1566.001 | ## 项目结构 ``` threat-hunting-platform/ ├── sysmon/ │ ├── baseline/ # SwiftOnSecurity-style baseline config │ ├── configs/ # Advanced + minimal configs │ └── custom-rules/ # Injection, LOLBAS, persistence rules ├── wazuh/ │ ├── custom-decoders/ # Sysmon + Windows Security decoders │ ├── rules/ # 15 hunting rules + 7 correlation rules │ └── agents/ # Windows agent config with Sysmon collection ├── elastic/ │ ├── kibana-queries/ # 15 KQL/EQL hunting queries (JSON) │ ├── dashboards/ # Kibana dashboard export (NDJSON) │ └── index-patterns/ # Sysmon + Wazuh index patterns ├── hunting-queries/ │ ├── lolbas/ # Hunt guides: rundll32, certutil, regsvr32, mshta │ ├── process-injection/ # Hunt guides: remote thread, LSASS, hollowing │ ├── persistence/ # Hunt guides: registry, schtask, service │ └── network-anomalies/ # Hunt guides: C2 beacon, DNS tunnel, scripting ├── simulations/ │ ├── attack-scenarios/ # 5 attack simulation scripts │ └── results/ # Hunt reports and simulation results ├── scripts/ │ ├── deploy-sysmon.ps1 # PowerShell: install/update/verify/uninstall Sysmon │ ├── parse-logs.py # Pull + normalize Sysmon logs from Elastic │ └── run-hunt.py # Run all hunting queries + generate MD report ├── playbooks/ │ ├── hunting-playbook.md # 6-chapter threat hunting methodology guide │ └── findings-report.md # Realistic hunt findings with evidence ├── docs/ │ └── setup-guide.md # Complete 10-step deployment guide ├── requirements.txt ├── .env.example └── README.md ``` ## 快速开始 ### 1. 安装依赖 ``` pip3 install -r requirements.txt --break-system-packages cp .env.example .env && nano .env ``` ### 2. 在 Windows 端点上部署 Sysmon ``` .\scripts\deploy-sysmon.ps1 -Mode Install ` -ConfigPath .\sysmon\configs\sysmonconfig-advanced.xml ``` ### 3. 加载 Wazuh 解码器和规则 ``` sudo cp wazuh/custom-decoders/*.xml /var/ossec/etc/decoders/ sudo cp wazuh/rules/*.xml /var/ossec/etc/rules/ sudo systemctl restart wazuh-manager ``` ### 4. 运行您的第一次狩猎 ``` python3 scripts/run-hunt.py --hunt all --timeframe 24h --output md ``` ### 5. 运行攻击模拟 ``` python3 simulations/attack-scenarios/simulate-lolbas.py python3 simulations/attack-scenarios/simulate-full-attack-chain.py ``` ## 狩猎查询 运行特定类别或单个查询: ``` # 所有查询 python3 scripts/run-hunt.py --hunt all --timeframe 24h # 仅 LOLBAS 类别 python3 scripts/run-hunt.py --hunt LOLBAS --timeframe 6h # 单个查询 python3 scripts/run-hunt.py --hunt lolbas-002 --timeframe 1h # 导出为 JSON python3 scripts/run-hunt.py --hunt all --output json ``` ## 日志解析 ``` # 解析最近 6 小时的所有 Event ID 10 (ProcessAccess) python3 scripts/parse-logs.py --event-id 10 --timeframe 6h --output csv # 解析特定 agent 的所有 Sysmon 事件 python3 scripts/parse-logs.py --event-id all --agent WIN10-VICTIM --output md # 解析网络连接 (Event ID 3) python3 scripts/parse-logs.py --event-id 3 --timeframe 24h --output json ``` ## 攻击模拟 ``` python simulate-lolbas.py # LOLBAS techniques python simulate-process-injection.py # Injection indicators python simulate-persistence.py # Persistence mechanisms python simulate-lateral-movement.py # Lateral movement python simulate-full-attack-chain.py # Full 6-stage kill chain ``` 模拟后预期触发的规则: - `100202` — certutil 解码 - `100206` — PowerShell 编码 - `100209` — schtasks + PowerShell - `100215` — LSASS GrantedAccess - `100300` — LOLBAS + 横向移动关联 ## 检测结果 | 指标 | 数值 | |--------|-------| | 检测规则总数 | 22 (15 条狩猎 + 7 条关联) | | 覆盖的 Sysmon Event ID | 13 (1,2,3,5,6,7,8,10,11,12,13,17,18,19,20,21,22) | | 狩猎查询 | 15 条 KQL/EQL | | 模拟攻击阶段 | 6 (完整杀伤链) | | 检测率 (模拟) | 100% | | 平均告警延迟 | ~5 秒 | | 误报率 (调优后) | < 2% | ## 技术栈 | 组件 | 版本 | 角色 | |-----------|---------|------| | Sysmon | 15.x | 端点遥测 | | Wazuh | 4.x | SIEM + 规则引擎 | | Elasticsearch | 8.x | 日志存储 + 搜索 | | Kibana | 8.x | 可视化 + 狩猎 | | Python | 3.10+ | 自动化脚本 | | Kali Linux | 2024.x | 管理主机 | ## 相关项目 | # | 项目 | 状态 | |---|---------|--------| | 01 | HomeSOC-Enterprise | ✅ 完成 | | 02 | 检测工程 | ✅ 完成 | | 03 | SOAR 自动化 | ✅ 完成 | | **04** | **威胁狩猎平台** | ✅ **本项目** | | 05 | Zeek NSM | ✅ 完成 | | 06 | Cloud SOC Canada | ✅ 完成 | | 07 | 恶意软件分析流水线 | ✅ 完成 | | 08 | 钓鱼模拟 | ✅ 完成 | | 09 | 漏洞管理仪表板 | ✅ 完成 | | 10 | AI SOC Triage | ✅ 完成 | ## 作者 **Reinhard** | EC-Council CCT GitHub: [github.com/Reinhard1268](https://github.com/Reinhard1268) 目标职位:安全分析师 / 渗透测试工程师 环境配置:Kali Linux | 32GB RAM | Docker | Wazuh | Elastic | Sysmon
标签:AI合规, DevSecOps, EDR, Elasticsearch, EQL, HTTP/HTTPS抓包, KQL, LOLBAS, PB级数据处理, PE 加载器, Redis利用, SSH蜜罐, Sysmon, Wazuh, 上游代理, 威胁狩猎平台, 安全仪表盘, 安全分析, 安全检测规则, 安全运维, 开源安全工具, 态势感知, 攻击模拟, 端点安全, 网络安全, 网络异常检测, 脆弱性评估, 补丁管理, 越狱测试, 进程注入, 逆向工具, 逆向工程平台, 隐私保护, 驱动签名利用