anmolksachan/ThreatTracer

GitHub: anmolksachan/ThreatTracer

ThreatTracer 是一款聚合多源漏洞情报的命令行工具,通过组件名或 CVE ID 快速检索漏洞利用信息并生成风险评级报告。

Stars: 153 | Forks: 25

image **CVE 情报与漏洞利用搜寻 CLI** *专为渗透测试人员 · 红队 · 漏洞赏金猎人 · 安全研究人员打造* [![Python](https://img.shields.io/badge/python-3.10%2B-blue?style=flat-square)](https://python.org) [![License](https://img.shields.io/badge/license-MIT-green?style=flat-square)](LICENSE) [![Version](https://img.shields.io/badge/version-5.0.0-orange?style=flat-square)](#) *作者:* **@FR13ND0x7F** · **@0xCaretaker** · **@meppohak5**
## 什么是 ThreatTracer? ThreatTracer 是一款命令行工具,能将产品名称、URL 或 CVE ID 瞬间转化为完整的漏洞利用情报报告。 它会并行查询 **NVD**、**Exploit-DB**、**GitHub PoC 仓库**、**CISA KEV**、**Nuclei Templates** 和 **Metasploit 模块**,让你无需手动翻查六个不同的标签页,即可在一个地方获取所有信息。 **v5.0 新特性 - 优先级排序与本地 AI 简报:** 现在每次扫描都会由确定性的优先级引擎(综合 KEV + EPSS + CVSS + 漏洞利用工具成熟度)进行风险评级,并且 `--summarize` 功能会将扫描结果转化为通俗易懂的分类简报。如果你运行的是**本地** LLM(Ollama 或任何兼容 OpenAI 的服务器),它将由 AI 撰写简报 —— 否则将由内置的启发式算法完成。**任何数据都不会离开你的设备。** 你还可以导出完整的 **Markdown / HTML 报告**(`--report`),并运行 `doctor` 命令一次性检查密钥、网络连通性和 LLM 就绪状态。 **v4.1 - 资产扫描:** 将其指向任何在线 URL,它会使用 Wappalyzer + header/body 分析自动识别技术栈指纹,然后对每个检测到的组件执行完整的 CVE + 漏洞利用情报扫描。 ## 功能概览 | 功能 | 描述 | |---|---| | 🔍 **CVE 查询** | 通过组件名称+版本、CPE 字符串或 CVE ID 查询 | | 🎯 **风险分类** | 确定性的 0-100 优先级评分:KEV + EPSS + CVSS + 漏洞成熟度 | | 🧠 **本地 AI 简报** | `--summarize` 通过本地 LLM 撰写通俗易懂的分类简报(离线) | | 📄 **报告** | `--report file.md` / `file.html` - HTML 可直接打印为 PDF | | 🩺 **Doctor** | 一条命令检查密钥、连通性、缓存和 LLM 就绪状态 | | 🌐 **资产扫描** | 识别在线 URL 指纹 → 针对各项技术自动进行 CVE 扫描 | | 📦 **批量扫描** | 支持并发控制,从文件中扫描多个 URL | | 💥 **Exploit-DB** | 本地索引的 CSV,通过 CVE ID + 模糊标题匹配 | | 🐙 **GitHub PoCs** | Trickest 镜像 + GitHub API(按 star 排序,过滤 fork) | | 🐳 **Vulhub** | 自动发现基于 Docker 的 PoC 环境 | | 🔥 **CISA KEV** | 已知被利用漏洞目录 - 首要的分类信号 | | ⚡ **Nuclei Templates** | 来自 ProjectDiscovery 的即用型模板 | | 🎯 **Metasploit** | 模块查询,附带直接的 `use` 命令 | | 📊 **EPSS 评分** | 漏洞利用预测概率 (FIRST.org) | | 🧠 **智能 CPE 匹配** | Rapidfuzz 相似度评分 + 供应商标准化 | | 💾 **SQLite 缓存** | 基于 TTL 的缓存 - 重复查询快,离线友好 | | 📤 **输出模式** | 表格 · JSON · CSV · 静默 | | 🔑 **API 密钥存储** | NVD + GitHub token 存储在 `~/.threattracer/` | ## 情报来源 | 来源 | 你将获得什么 | 是否需要认证 | |---|---|---| | [NVD API v2](https://nvd.nist.gov/developers) | CVEs, CVSS v3, CPEs | 可选(提高速率限制) | | [EPSS](https://www.first.org/epss/) | 漏洞利用概率评分 0–1 | 否 | | [CISA KEV](https://www.cisa.gov/known-exploited-vulnerabilities-catalog) | 野外活跃利用的漏洞 | 否 | | [Exploit-DB](https://www.exploit-db.com) | 漏洞利用脚本、类型、平台 | 否 | | [Trickest CVE](https://github.com/trickest/cve) | 每个 CVE 的 GitHub PoC URL 列表 | 否 | | [GitHub API](https://docs.github.com/en/rest) | 按 star 排名的 PoC 仓库 | 可选(推荐) | | [Vulhub](https://github.com/vulhub/vulhub) | Docker PoC 环境 | GitHub token | | [Nuclei Templates](https://github.com/projectdiscovery/nuclei-templates) | 即用型测试模板 | 可选 | | [Metasploit](https://github.com/rapid7/metasploit-framework) | 包含 CVE 引用的模块索引 | 否 | ## 安装 **环境要求:** Python 3.9+(推荐且经过 CI 测试的是 3.10+) ``` # 克隆仓库 git clone https://github.com/anmolksachan/ThreatTracer.git cd ThreatTracer # 安装基础工具(创建 `threattracer` 命令) pip install -e . # 可选:为 `asset` 扫描添加实时 URL 指纹识别(Wappalyzer) pip install -e ".[asset]" # 验证所有内容 - keys、连通性、cache 和本地 LLM threattracer doctor ``` ## API 密钥 ThreatTracer 无需任何 API 密钥即可运行,但添加密钥可解锁更高的速率限制和更丰富的情报。 ``` # 存储一次 - 每次扫描自动加载 threattracer config --nvd-key YOUR_NVD_KEY threattracer config --github-token YOUR_GITHUB_TOKEN # 或使用环境变量 export NVD_API_KEY=your_key export GITHUB_TOKEN=your_token ``` | 密钥 | 获取地址 | 解锁内容 | |---|---|---| | NVD API key | https://nvd.nist.gov/developers/request-an-api-key | 30秒内50次请求,而不是5次 | | GitHub token | https://github.com/settings/tokens (`public_repo` scope) | PoC star 数,Vulhub,Nuclei 索引 | ## 命令 ``` threattracer --help Commands: scan CVE lookup by component name, CPE string, or CVE ID asset Fingerprint a live URL and auto-scan all detected technologies config Store API keys permanently sync Re-download the local Exploit-DB index cache-cmd Manage the local SQLite response cache ``` ## `scan` - CVE 查询 ### 按组件名称 + 版本 ``` # 基础扫描 threattracer scan -c apache -v 2.4.51 # 带有每个 CVE 的完整详情面板 threattracer scan -c nginx -v 1.18.0 --detail # Log4Shell threattracer scan -c log4j -v 2.14.1 --detail # WordPress threattracer scan -c wordpress -v 6.4.1 # 过滤为仅 critical,按 EPSS score 排序 threattracer scan -c openssl -v 3.0.7 --severity critical --sort epss # 仅显示 2022 年起的 CVE threattracer scan -c struts -v 2.5.10 --since 2022 --limit 20 # 按 KEV 排序 - 主动利用优先 threattracer scan -c apache -v 2.4 --sort kev ``` ### 按 CVE ID ``` # 查找特定 CVE threattracer scan --cve CVE-2021-44228 # 完整详情 - CVSS 分解、exploits、PoCs、Nuclei、MSF threattracer scan --cve CVE-2021-44228 --detail # 用于管道操作的 JSON 输出 threattracer scan --cve CVE-2021-44228 -o json # Apache Struts RCE(Equifax breach) threattracer scan --cve CVE-2017-5638 --detail # HTTP/2 Rapid Reset threattracer scan --cve CVE-2023-44487 --detail # 跳过缓慢检查以进行快速 triage threattracer scan --cve CVE-2023-44487 --no-epss --no-msf ``` ### 按 CPE 字符串 ``` threattracer scan --cpe "cpe:2.3:a:apache:log4j:2.14.1:*:*:*:*:*:*:*" threattracer scan --cpe "cpe:2.3:a:nginx:nginx:1.18.0:*:*:*:*:*:*:*" threattracer scan --cpe "cpe:2.3:a:php:php:8.1.0:*:*:*:*:*:*:*" --severity critical,high ``` ### 输出模式 ``` # 默认:rich table threattracer scan -c apache -v 2.4.51 # JSON - 管道传递给 jq,保存到文件,发送至 SIEM threattracer scan -c apache -v 2.4.51 -o json threattracer scan -c apache -v 2.4.51 -o json | jq '.summary' threattracer scan -c apache -v 2.4.51 -o json | jq '.cves[] | select(.in_kev == true)' # CSV - 导入到 Excel 或 ticketing system threattracer scan -c nginx -v 1.18 -o csv > nginx-report.csv # Silent - 用于 CI/CD 脚本(exit 0 = 过滤后无匹配) threattracer scan -c apache -v 2.4 --severity critical -o silent ``` ### 过滤与排序 ``` --severity critical # Single severity --severity critical,high # Multiple severities --sort cvss # Highest CVSS first (default) --sort epss # Highest exploit probability first --sort kev # CISA KEV entries first, then CVSS --sort published # Newest CVEs first --since 2023 # Only CVEs from 2023+ --limit 10 # Cap results ``` ## `asset` - 在线 URL 指纹识别 + CVE 扫描 将 ThreatTracer 指向一个在线 URL。它会: 1. 抓取页面并跟随重定向 2. 通过 **Wappalyzer** + HTTP header 分析 + HTML body 模式检测技术 3. 对每个检测到版本的技术,运行完整的 CVE + 漏洞利用扫描 4. 按技术展示结果,并附带综合摘要 ### 检测的技术(内置,无需 Wappalyzer) `Apache HTTP Server` · `nginx` · `Microsoft IIS` · `LiteSpeed` · `Jetty` · `Apache Tomcat` · `OpenSSL` · `PHP` · `ASP.NET` · `Express` · `Next.js` · `WordPress` · `Drupal` · `Joomla` · `Laravel` · `Django` · `Spring Framework` · `Apache Struts` · `Confluence` · `Jira` · `Jenkins` · `GitLab` · `Grafana` · `Apache Solr` · `Elasticsearch` · `Ruby on Rails` ### 单一目标 ``` # 基础 threattracer asset https://example.com # 带有完整 CVE 详情面板 threattracer asset https://example.com --detail # 优先处理主动利用的 CVE threattracer asset https://target.com --severity critical --sort kev # 内部 / 非标准端口 threattracer asset http://10.10.10.5 threattracer asset http://192.168.1.1:8080 # 用于自动化的 JSON threattracer asset https://target.com -o json ``` ### 批量模式 **`targets.txt` 格式:** ``` # 以 # 开头的行将被忽略 https://example.com https://api.example.com http://10.10.10.5:8080 https://staging.example.com ``` ``` # 扫描所有目标(默认 3 个并发) threattracer asset --file targets.txt # 增加 concurrency 以提高速度 threattracer asset --file targets.txt --concurrency 5 # 跨所有目标过滤 threattracer asset --file targets.txt --severity critical,high --sort kev # 所有目标的 JSON 输出 threattracer asset --file targets.txt -o json > batch-results.json # 每个目标的完整详情面板 threattracer asset --file targets.txt --detail ``` ### 漏洞赏金工作流 ``` # 使用 Subfinder 进行子域名扫描 subfinder -d example.com -silent | sed 's|^|https://|' > subs.txt threattracer asset --file subs.txt --concurrency 10 --severity critical,high # 首先使用 httpx 进行存活主机过滤 subfinder -d example.com -silent | httpx -silent > live.txt threattracer asset --file live.txt --concurrency 5 --sort kev # 查找武器化目标(MSF 或 KEV) threattracer asset --file targets.txt -o json | \ jq '.[] | select(.weaponised_count > 0) | {url, weaponised_count}' # 查找可使用 Nuclei 测试的漏洞 threattracer asset https://target.com -o json | \ jq '.[].cve_results[].records[] | select(.nuclei_templates | length > 0) | {cve_id, nuclei_templates}' ``` ### 渗透测试工作流 ``` # 对单个目标进行全面 triage threattracer asset https://target.com --detail --sort kev # 查找 Metasploit-ready 漏洞 threattracer asset https://target.com -o json | \ jq '.[].cve_results[].records[] | select(.msf_modules | length > 0) | {cve_id, msf_modules}' # 内部网络扫描 printf 'http://10.10.10.%s\n' {1..254} > internal.txt threattracer asset --file internal.txt --concurrency 5 --severity critical # 将发现结果导出为 CSV 以用于报告 threattracer asset https://target.com -o csv > pentest-findings.csv ``` ## 理解输出结果 ### CVE 表格 ``` Sev CVE ID CVSS EPSS% AV PR EDB PoC Nuclei MSF KEV Published 🔴 CVE-2021-44228 10.0 97.5% NET NONE ✓ ✓ ✓ ✓ 🔥 2021-12-10 🟠 CVE-2022-23302 8.8 2.1% NET LOW ✗ ✓ ✗ ✗ 2022-01-18 ``` | 列名 | 含义 | |---|---| | **Sev** | 🔴 严重 · 🟠 高危 · 🟡 中危 · 🟢 低危 | | **CVSS** | CVSS v3 基础评分(回退到 v2) | | **EPSS%** | 未来 30 天内被利用的概率 | | **AV** | 攻击向量:NET=网络, ADJ=相邻, LOCAL=本地, PHY=物理 | | **PR** | 所需权限:NONE=无 / LOW=低 / HIGH=高 | | **EDB** | ✓ = 存在 Exploit-DB 条目 | | **PoC** | ✓ = 找到 GitHub PoC 仓库 | | **Nuclei** | ✓ = 有可用的 ProjectDiscovery Nuclei 模板 | | **MSF** | ✓ = 有可用的 Metasploit 模块 | | **KEV 🔥** | 确认存在活跃利用 - CISA 已知被利用漏洞 | ### 扫描摘要 ``` ╭─ Scan Summary ────────────────╮ │ Total CVEs: 47 │ │ Critical: 3 │ │ High: 12 │ │ With Exploits: 8 │ │ Nuclei Ready: 5 │ │ MSF Modules: 2 │ │ 🔥 In CISA KEV: 3 │ ╰───────────────────────────────╯ ``` ## 渗透测试配方 ``` # TRIAGE:此目标上最危险的是什么? threattracer asset https://target.com --sort kev --severity critical --detail # QUICK CHECK:此 CVE 当前是否可利用? threattracer scan --cve CVE-2023-44487 --detail # NUCLEI PIPELINE:查找易受攻击的 CVE 然后触发 templates threattracer scan -c nginx -v 1.14 -o json | \ jq -r '.cves[] | select(.nuclei_templates | length > 0) | .cve_id' | \ xargs -I{} nuclei -t cves/ -id {} # MSF PIPELINE:查找并获取 module path threattracer scan -c struts -v 2.3 -o json | \ jq -r '.cves[] | select(.msf_modules | length > 0) | .msf_modules[0].fullname' # KEV FILTER:什么已在野外被确认利用? threattracer scan -c wordpress -v 5.8 -o json | \ jq '.cves[] | select(.in_kev == true) | {cve_id, kev_date_added, kev_ransomware_use}' # EPSS TRIAGE:接下来最有可能被利用的 threattracer scan -c apache -v 2.4 --sort epss --limit 5 --detail # CI/CD GATE:如果发现 critical CVE 则使构建失败 threattracer scan -c log4j -v 2.14 --severity critical -o silent || exit 1 # SUBFINDER PIPELINE subfinder -d target.com -silent | httpx -silent | sed 's|^|https://|' | \ threattracer asset --file /dev/stdin --concurrency 10 --severity critical,high -o json ``` ## 分类与本地 AI 简报 在任何 `scan` 或 `asset` 命令中添加 `--summarize` (`-s`) 即可获得两项额外内容: 1. **一份按风险排名的“优先发现”表格。** 每个 CVE 都会获得一个确定性的 **0-100 优先级评分**,该评分融合了四个独立的公开信号: | 信号 | 权重 | 原因 | |---|---|---| | CISA KEV 收录 | 40 | 确认的真实世界利用 - 最强信号 | | EPSS | 25 | FIRST.org 预测的未来 30 天内利用概率 | | CVSS 基础评分 | 20 | 理论严重程度 | | 漏洞利用工具成熟度 | 15 | PoC → Exploit-DB/Nuclei → Metasploit/KEV | 该评分是关于补丁/验证顺序的**决策支持** - 并不声称在你的特定环境中任何漏洞都是可利用的。 2. **一份通俗易懂的分类简报** - 整体安全态势、应首先关注的内容及其原因,以及防御性的后续步骤。 ``` # 终端中的 Triage 表格和简报 threattracer scan -c apache -v 2.4.51 --summarize # Asset 扫描,对所有发现进行 triage,编写 HTML 报告(可打印为 PDF) threattracer asset https://target.com -s --report target.html # 显式选择后端和模型 threattracer scan --cve CVE-2021-44228 -s --llm-provider ollama --llm-model qwen2.5 ``` ### 可选的本地 LLM(100% 离线) 如果能够连接到某个**本地**模型,简报将由其撰写;否则将使用内置的确定性启发式算法。**绝不会向云端服务发送任何信息**,并且扫描绝不会因为 LLM 不可用而失败。 支持两种后端: ``` # 选项 A - Ollama(推荐,最简单) ollama serve ollama pull llama3.2 threattracer config --llm-provider ollama --llm-model llama3.2 # 选项 B - 任何兼容 OpenAI 的本地服务器(llama.cpp、LM Studio、vLLM,...) threattracer config --llm-provider openai --llm-openai-url http://localhost:8080 --llm-model your-model ``` `--llm-provider auto`(默认值)会首先探测 Ollama,然后探测兼容 OpenAI 的服务器,最后回退到启发式算法。使用以下命令检查检测到了什么: ``` threattracer doctor ``` 对应的环境变量(参见 `.env.example`):`THREATTRACER_LLM_PROVIDER`, `THREATTRACER_LLM_OLLAMA_URL`, `THREATTRACER_LLM_OPENAI_URL`, `THREATTRACER_LLM_MODEL`。 ## `doctor` - 环境检查 ``` threattracer doctor ``` 报告 API-key 状态、NVD / EPSS / CISA KEV / GitHub 的可达性、缓存位置,以及本地 LLM 是否可用于 `--summarize`。每当扫描缓慢或返回空结果时,请首先运行此命令。 ## 报告 ``` threattracer scan -c wordpress -v 6.4.1 -s --report wp.md # Markdown threattracer asset https://target.com -s --report target.html # HTML → print to PDF ``` 报告包含执行摘要、一目了然的指标面板、优先发现表格以及针对每个 CVE 的完整详情。HTML 是一个包含内联 CSS 的独立文件,可从任何浏览器清晰地打印为 PDF。 ## `config` - 密钥管理 ``` threattracer config --nvd-key YOUR_NVD_KEY threattracer config --github-token YOUR_GITHUB_TOKEN threattracer config --nvd-key YOUR_KEY --github-token YOUR_TOKEN ``` 密钥保存至 `~/.threattracer/config.json`,每次运行时自动加载。 ## `sync` - 更新 Exploit-DB ``` threattracer sync # ✓ Exploit-DB 已同步:48,320 条 entries。 ``` ## `cache-cmd` - 缓存控制 ``` threattracer cache-cmd --purge-expired # remove stale entries only threattracer cache-cmd --clear # wipe everything ``` 缓存位置:`~/.threattracer/cache.db`(TTL:每个条目 6 小时) ## 项目结构 ``` ThreatTracer/ ├── pyproject.toml ├── Dockerfile ├── .env.example ├── CHANGELOG.md ├── threattracer/ │ ├── main.py # Entry point │ ├── cli/ │ │ ├── __init__.py # All CLI commands (scan, asset, doctor, config, …) │ │ ├── output.py # Rich tables, panels, triage & briefing render │ │ └── report.py # Markdown / HTML report writer │ ├── core/ │ │ ├── scanner.py # Async orchestrator │ │ ├── nvd.py # NVD API v2 + EPSS │ │ ├── cpe.py # CPE search + fuzzy ranking │ │ ├── exploitdb.py # Exploit-DB CSV index │ │ ├── github_poc.py # Trickest + GitHub API + Vulhub │ │ ├── kev.py # CISA KEV catalog │ │ ├── nuclei_check.py # Nuclei template discovery (bounded) │ │ ├── msf_check.py # Metasploit module lookup │ │ ├── asset_scanner.py # URL fingerprinting + per-tech CVE scan │ │ ├── triage.py # Deterministic 0-100 risk prioritisation │ │ └── llm_summary.py # Optional local-LLM briefing + heuristic fallback │ └── utils/ │ ├── models.py # Pydantic data models (+ triage/summary models) │ ├── config.py # Configuration loading (+ LLM settings) │ ├── cache.py # Async SQLite TTL cache │ ├── http_client.py # httpx + tenacity retry │ └── validate.py # CVE-ID validation helpers └── tests/ ├── test_nvd.py ├── test_cpe.py ├── test_exploitdb.py ├── test_validate.py ├── test_triage.py ├── test_llm_summary.py ├── test_report.py └── test_guards.py ``` ## 运行测试 ``` pip install -e ".[dev]" pytest tests/ -v ``` ## 依赖项 | 包 | 用途 | |---|---| | `httpx[http2]` | 支持 HTTP/2 的异步 HTTP | | `rich` | 终端 UI - 表格、面板、进度条 | | `typer` | CLI 框架 | | `pydantic` | 数据验证与模型 | | `rapidfuzz` | 模糊 CPE 匹配 | | `aiosqlite` | 异步 SQLite 缓存 | | `tenacity` | 带有指数退避的重试 | | `anyio` | 异步后端 | | `python-Wappalyzer` | 技术指纹识别*(可选,推荐)* | ## 故障排除 **被 NVD 限制速率?** ``` threattracer config --nvd-key YOUR_KEY # 50 req/30s vs 5 req/30s ``` **PoC 链接未显示?** ``` threattracer config --github-token YOUR_TOKEN ``` **Nuclei 模板缺失?** ``` threattracer config --github-token YOUR_TOKEN # needed to browse template index ``` **结果过时/错误?** ``` threattracer cache-cmd --clear ``` **扫描缓慢?** ``` threattracer scan -c apache -v 2.4 --no-epss --no-msf --no-nuclei ``` **Wappalyzer 未检测到技术?** ``` pip install python-Wappalyzer # 没有它,Header/body 指纹识别仍然有效 ``` ## 延伸阅读 版本 1:[使用 CVE 检查脚本增强渗透测试 - ThreatTracer](_URL_12/>)
版本 3:[ThreatTracer 3.0:为现代防御者重新定义漏洞情报](https://anmolksachan.medium.com/threattracer-3-0-redefining-vulnerability-intelligence-for-modern-defenders-7661ffc11873)
[ThreatTracer:用于 CVE 跟踪、PoC 查找和风险分析的开源工具](https://www.xpert4cyber.com/2026/01/threattracer-open-source-cve-tracking-poc-lookup-risk-analysis.html)
版本 4.1:[六个浏览器标签页和一个电子表格。总有更好的办法。](https://anmolksachan.medium.com/six-browser-tabs-and-a-spreadsheet-there-had-to-be-a-better-way-6575f6b0f0c7) ## 免责声明 ThreatTracer 仅用于**授权的安全测试、漏洞研究和教育目的**。 对你不拥有或没有明确书面测试许可的系统使用此工具是非法的。作者对滥用行为不承担任何责任。 ## 鸣谢 **ThreatTracer** — `@FR13ND0x7F` · `@0xCaretaker` · `@meppohak5` **v4.1 架构** — 引入资产扫描、CISA KEV、Nuclei、Metasploit 和 EPSS 的异步重写。 数据提供方:[NVD/NIST](https://nvd.nist.gov) · [FIRST.org EPSS](https://www.first.org/epss) · [CISA KEV](https://www.cisa.gov/known-exploited-vulnerabilities-catalog) · [Exploit-DB](https://www.exploit-db.com) · [Trickest](https://github.com/trickest/cve) · [ProjectDiscovery](https://github.com/projectdiscovery/nuclei-templates) · [Rapid7](https://github.com/rapid7/metasploit-framework) · [Vulhub](https://github.com/vulhub/vulhub)
负责任地进行猎杀。
标签:AI风险缓解, DInvoke, Petitpotam, Python, XSS, 实时处理, 无后门, 无服务器架构, 本地大模型, 漏洞情报, 资产指纹识别, 逆向工具