gmcleod1/threat-intel-tools

GitHub: gmcleod1/threat-intel-tools

该项目提供从非结构化文本中提取 IOC 并通过 VirusTotal 富化后格式化为 MISP 和 STIX 2.1 标准的威胁情报自动化工具集。

Stars: 0 | Forks: 0

# 威胁情报工具 [![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/ad/ad5834178f7599af9fdda11629d49cae07f2997beec49821b2920eff5bfd50e7.svg)](https://github.com/gmcleod1/threat-intel-tools/actions/workflows/ci.yml) 用于 IOC 提取、富化和报告的自动化工具。从非结构化文本中提取指标,通过 VirusTotal/Shodan 进行富化,并格式化以适配 MISP 和其他平台。 ## 工具概述 ### IOC 提取器 解析非结构化文本(报告、日志、描述)并提取结构化指标: - **IP 地址:** IPv4, IPv6(排除私有/内部范围) - **域名:** FQDN 和子域名 - **哈希值:** MD5, SHA1, SHA256, SSDEEP - **URL:** HTTP/HTTPS, 文件路径 - **电子邮件地址:** User@domain 格式 - **注册表路径:** Windows 注册表位置(恶意软件持久化指标) 输出:用于进一步富化的结构化 JSON ### VirusTotal 富化器 通过 VirusTotal API 批量富化指标: - 文件哈希:检测率、首次提交、最后提交、文件名 - URL:最后提交日期、SafeURL 状态 - 域名:DNS 解析历史、WHOIS 信息 - IP 地址:ASN、国家/地区、威胁类别 输出:带有置信度得分的富化 IOC 报告 ### MISP 格式化程序 将 IOC 格式化以便导入 MISP(Malware Information Sharing Platform): - 包含元数据的事件创建 - 属性标准化(MISP 对象类型) - 关系映射(file→URL→domain→IP) - TLP 和共享限制 - 导出为 MISP JSON 格式 ### STIX 格式化程序 将 IOC 格式化为 STIX 2.1 bundle(用于 TAXII 2.1 集合或原生支持 STIX 的平台): - 每个 IOC 对应一个 `Indicator` SDO,带有正确的 STIX pattern(`[ipv4-addr:value = '...']`, `[file:hashes.'SHA-256' = '...']` 等) - 一个 `Grouping` SDO 将一次运行中的所有指标捆绑在一起,作为一个可报告单元 - 通过 STIX `marking-definition` 对象应用 TLP(white/green/amber/red) - 基于官方 [`stix2`](https://pypi.org/project/stix2/) 库构建,因此其输出符合 STIX 2.1 规范验证 ## 项目结构 ``` threat-intel-tools/ README.md # This file ioc-extractor.py # Parse and extract indicators vt-enricher.py # VirusTotal API integration misp-formatter.py # Format for MISP platform stix-formatter.py # Format as a STIX 2.1 bundle tests/ # pytest suite (unit + end-to-end pipeline tests) .github/workflows/ci.yml # CI: tests on Python 3.11-3.14 config/ vt-api-key.example.txt # VirusTotal API key template misp-config.example.yml # MISP instance config template reports/ ioc-report-template.md # Intelligence report template ioc-summary-template.txt # Plaintext IOC list template examples/ sample-report.txt # Example malware report for IOC extraction ``` ## 快速开始 ### 1. 设置 VirusTotal API ``` cp config/vt-api-key.example.txt config/vt-api-key.txt # 将你的 VirusTotal API key 添加到 config/vt-api-key.txt ``` ### 2. 从报告中提取 IOC ``` python ioc-extractor.py --file reports/my-report.txt --output iocs.json ``` ### 3. 使用 VirusTotal 进行富化 ``` python vt-enricher.py --iocs iocs.json --output enriched-iocs.json ``` ### 4. 生成情报报告 ``` python reports/build-report.py --enriched enriched-iocs.json --output threat-report.md ``` ### 5. 格式化以用于共享(MISP 或 STIX/TAXII) ``` python misp-formatter.py --iocs iocs.json --info "Emotet campaign 2026-06" --tlp amber --output misp-event.json python stix-formatter.py --iocs iocs.json --name "Emotet campaign 2026-06" --tlp amber --output stix-bundle.json ``` ## IOC 类型和示例 | 类型 | 示例 | 用例 | |------|----------|----------| | 文件哈希 (MD5) | `5d41402abc4b2a76b9719d911017c592` | 恶意软件识别 | | 文件哈希 (SHA256) | `2c26b46911185131006ba493dcf7b41b` | 恶意软件追踪 | | IPv4 地址 | `192.0.2.1`, `8.8.8.8` | C2 服务器, 恶意软件信标 | | 域名 | `evil.com`, `c2.attacker.com` | C2 基础设施 | | URL | `http://evil.com/malware.exe` | 网络钓鱼, 有效载荷分发 | | 电子邮件 | `attacker@evil.com` | 威胁行为者联系方式 | | 注册表路径 | `HKLM\Software\Policies\Microsoft\Windows` | 持久化机制 | | 文件路径 | `C:\Windows\Temp\bad.exe` | 恶意软件位置指标 | ## 工作流程 1. **收集** 来自各种来源(报告、日志、分析)的情报 2. **提取** 从非结构化文本中提取结构化 IOC 3. **富化** 使用 VirusTotal, Shodan, WHOIS 数据进行富化 4. **验证** 指标(误报、过期的基础设施) 5. **关联** 相关指标(file→URL→domain→IP) 6. **报告** 附带置信度得分和 TLP 的调查结果 7. **共享** 通过 MISP 或其他威胁情报平台共享 8. **追踪** 指标随时间变化的有效性 ## 情报报告结构 威胁情报报告遵循以下标准结构: - **执行摘要:** 高层概述、受影响方、建议 - **失陷指标:** 包含类型和来源的结构化 IOC 表格 - **基础设施分析:** C2 服务器、托管、DNS、WHOIS 信息 - **行为分析:** MITRE ATT&CK 技术、能力 - **威胁行为者画像:** (如果适用)归属、目标、已知活动 - **建议:** 检测规则、防御措施、威胁狩猎查询 - **附录:** 完整的技术细节、原始数据、分析工件 ## 测试 pytest 测试套件涵盖了提取回归测试(Defang 处理、私有 IP 过滤、注册表路径边界)、STIX 2.1 输出(使用官方 `stix2patterns` 语法验证器检查每一个生成的 pattern、hive normalization、TLP 标记)、MISP 事件结构,以及端到端 CLI 运行(包括错误路径退出代码)。CI 会在每次推送时于 Python 3.11–3.14 上运行该套件。 ``` pip install -r requirements-dev.txt pytest ``` ## 资源 - [VirusTotal API 文档](https://developers.virustotal.com) - [MISP 项目](https://www.misp-project.org) - [Shodan 搜索引擎](https://www.shodan.io) - [威胁情报最佳实践](https://www.misp-project.org/best-practices/) - [TLP 交通灯协议](https://www.first.org/tlp/) ## API 密钥和配置 **重要提示:** 切勿将 API 密钥或凭据提交到 git。 从模板创建本地配置文件: ``` cp config/vt-api-key.example.txt config/vt-api-key.txt cp config/misp-config.example.yml config/misp-config.yml ``` 这些文件已在 git 中被忽略,并包含您的个人凭据。 **最后更新:** 2026 年 6 月 15 日
标签:IOC提取, STIX, 威胁情报, 安全规则引擎, 开发者工具, 网络信息收集, 逆向工具