Virtualhaggis/usecaseintel

GitHub: Virtualhaggis/usecaseintel

从The Hacker News威胁文章自动提取ATT&CK指标并生成经过验证的Splunk和Defender检测规则,帮助蓝队将最新威胁情报快速转化为可执行的检测逻辑。

Stars: 0 | Forks: 0

# THN 威胁图谱 — Splunk + Defender 用例生成器 从 [The Hacker News](https://thehackernews.com/) 拉取最新的 10 篇文章, 提取安全指标 + ATT&CK 技术 + 杀伤链阶段,并 为每篇文章自动生成 Splunk SPL(符合 CIM 标准)和 Microsoft Defender Advanced Hunting KQL 检测规则。 ## 文件结构 ``` thn-usecases/ generate.py ← Build the static site (index.html) sync.py ← Pull authoritative sources -> registry.json validate.py ← Verify generate.py SPL + ATT&CK refs are spec-valid data_sources/ registry.json ← Built by sync.py (CIM datasets, ESCU detections, ATT&CK) cim_spec_fields.json ← Hand-curated CIM 8.5 spec fields not seen in ESCU defender_spec_tables.json ← Hand-curated Defender XDR schema (Microsoft Learn) sync_log.json ← Last sync metadata validation_report.json ← Last validation result CHANGELOG.md ← Auto-appended by sync.py on each run index.html ← The generated site ``` ## 工作流 ``` +-------------+ +----------+ +---------------+ | sync.py | --> | registry | --> | validate.py | | (weekly) | | .json | | (every build) | +-------------+ +----------+ +---------------+ | v +-------------+ | generate.py | --> index.html | (daily) | +-------------+ ``` ### 1) `sync.py` — 拉取权威来源 拉取内容(无需认证,全部公开): - **Splunk Security Content (ESCU)** — `splunk/security_content` develop 分支 tarball。作为生产环境中 *实际* 使用的 CIM 数据集/字段的真实来源。 - **MITRE ATT&CK enterprise-attack STIX bundle** — `mitre-attack/attack-stix-data` master 分支。所有当前技术 ID + 名称 + 战术的规范列表。 构建 `data_sources/registry.json`,包含: - `cim_datasets` — `{full_path: [field_names]}`,源自真实的 ESCU SPL。 - `escu_detections` — 每个ESC U TTP/异常/狩猎检测规则的精简副本。 - `attack_techniques` — `{TID: {name, kill_chain_phases, deprecated}}`。 - `attack_tactics` — `{shortname: long_name}`。 每周运行(或按需运行): ``` py sync.py ``` ### 2) `validate.py` — 验证 SPL **和** KQL 模板 Splunk SPL 检查(针对每个 `UseCase`): - 提取 `from datamodel=X.Y` 和 `nodename="X.Y"` 引用。 - 提取 `Y.field_name` 引用。 - 检查数据集路径是否存在于 ESCU 用法或 `cim_spec_fields.json` 白名单中。 - 根据相同的集合检查每个字段是否有效。 Defender KQL 检查(针对每个 `UseCase`): - 识别每个被引用的 Defender XDR 表(`DeviceProcessEvents`、`EmailEvents`、`AADSignInEventsBeta` 等)。 - 提取 `| where Col`、`| project ...` 中的列引用(支持别名)。 - 根据在 `microsoft/Microsoft-365-Defender-Hunting-Queries` 中观察到的内容与手工整理的 `defender_spec_tables.json` 模式白名单的并集进行验证。 - 标记不在模式中的 Defender 样式的表名(例如拼写错误)。 ATT&CK 检查: - 每个技术 ID 存在于当前的 MITRE 目录中且未被弃用。 失败模式: - **错误** (exit 1) — 未知的 CIM 数据集/字段、未知的 Defender 表、缺失/已弃用的 ATT&CK ID。 - **警告** — 在任何引用的 Defender 表中未找到列名(可能是拼写错误或别名问题)。 - **信息** — 规范有效但未在生产语料库中使用的标识符(仍然通过)。 运行: ``` py validate.py ``` ### 3) `generate.py` — 构建站点 拉取最近的 10 篇 RSS 文章,运行规则引擎,渲染 HTML: ``` py generate.py ``` ## 权威文档 以下是流水线用于保持我们与其对齐的上游参考: ### Splunk - [Splunk CIM 8.5 — 概述](https://help.splunk.com/en/data-management/common-information-model/8.5/introduction/overview-of-the-splunk-common-information-model) - [CIM Endpoint 数据模型](https://docs.splunk.com/Documentation/CIM/latest/User/Endpoint) - [SPL Search 参考](https://docs.splunk.com/Documentation/Splunk/latest/SearchReference) - [搜索宏](https://help.splunk.com/en/splunk-enterprise/search/searchsyntax/9.5/searchmacros) - [Splunk Security Content (ESCU)](https://github.com/splunk/security_content) — 金牌标准的生产环境 SPL - [research.splunk.com](https://research.splunk.com) — 可搜索的检测目录 - [Splunk contentctl](https://github.com/splunk/contentctl) — Splunk 官方验证 CLI - [Splunkbase 上的 CIM Add-on](https://splunkbase.splunk.com/app/1621) ### Microsoft Defender / Sentinel - [Defender XDR Advanced Hunting 架构](https://learn.microsoft.com/en-us/defender-xdr/advanced-hunting-schema-tables) - [Microsoft 365 Defender Hunting 查询](https://github.com/microsoft/Microsoft-365-Defender-Hunting-Queries) - [Azure Sentinel 社区检测](https://github.com/Azure/Azure-Sentinel) ### 跨平台 - [MITRE ATT&CK 企业版](https://attack.mitre.org/techniques/enterprise/) - [MITRE attack-stix-data (规范 JSON)](https://github.com/mitre-attack/attack-stix-data) - [SigmaHQ 规则](https://github.com/SigmaHQ/sigma) — 供应商中立的检测格式 ## 更新 当 CIM 规范更改时(8.5 → 8.6 等),请从最新的 [Splunk CIM 文档](https://help.splunk.com/en/data-management/common-information-model) 数据模型页面手动更新 `cim_spec_fields.json` 白名单。 ESCU 和 ATT&CK 会在 `sync.py` 运行时自动刷新。差异会附加到 `CHANGELOG.md`,以便可以观察到偏移情况。 ## 调度 — 自动化运行 包含两个批处理包装脚本: | 脚本 | 功能 | 建议频率 | |---|---|---| | `run_daily.bat` | 验证 → 生成 → 摘要 (写入 `daily_digest.md`) | 每天,例如 08:00 | | `run_weekly.bat` | 同步 → 每日任务 | 每周,例如周一 06:00 | 两者均写入 `logs\_YYYY-MM-DD.log`。 `digest.py` 生成: - `daily_digest.md` — 自上次运行以来的新文章 + 所有高/严重等级内容的 Markdown 摘要 - `data_sources/last_run.json` — 下次运行差异比较的状态 - 当设置了 `WEBHOOK_URL` 环境变量时可选的 webhook POST(用于 Slack/Teams/email-relay) ### 注册 Windows 任务计划程序 以提升的权限在 `cmd` 或 PowerShell 中以 **你的用户身份** 运行(无需管理员权限): ``` schtasks /create /tn "THN Daily" /tr "C:\Users\mckec\Downloads\DexCore 1.1.9\thn-usecases\run_daily.bat" /sc daily /st 08:00 /f schtasks /create /tn "THN Weekly Sync" /tr "C:\Users\mckec\Downloads\DexCore 1.1.9\thn-usecases\run_weekly.bat" /sc weekly /d MON /st 06:00 /f ``` 可选 — 在注册之前设置系统级的 webhook URL: ``` setx WEBHOOK_URL "https://hooks.example.com/your-webhook" ``` 验证: ``` schtasks /query /tn "THN Daily" schtasks /query /tn "THN Weekly Sync" ``` 按需运行: ``` schtasks /run /tn "THN Daily" ``` 稍后移除: ``` schtasks /delete /tn "THN Daily" /f schtasks /delete /tn "THN Weekly Sync" /f ```
标签:CIM, Cloudflare, ESCU, KQL, Microsoft Defender, MITRE ATT&CK, Python, SPL, Threat Atlas, 后端开发, 多模态安全, 威胁情报, 威胁指标, 子域名暴力破解, 安全数据模型, 开发者工具, 无后门, 杀伤链, 用例生成, 网络安全, 自动化检测, 逆向工具, 隐私保护, 静态站点生成, 高级威胁狩猎, 黑客新闻