sonnycroco/nuclei-index

GitHub: sonnycroco/nuclei-index

一个将 CVE ID 映射到本地 nuclei-templates 并自动生成可执行 nuclei 扫描命令的轻量索引工具。

Stars: 0 | Forks: 0

# nuclei-index 映射 **CVE ID → 你本地的 [nuclei-templates](https://github.com/projectdiscovery/nuclei-templates)**,并返回一个可运行、有限速的 `nuclei` 命令。 漏洞情报告诉你目标上*哪些内容*是可被利用的。`nuclei-index` 则为你提供触发机制:用于验证它的精确 `nuclei` 调用命令。它会根据 CVE 索引本地的 nuclei-templates 检出,缓存结果,并将“适用 CVE-X”桥接为“运行此命令”。 - **零依赖。** 纯标准库 Python (≥3.9) 编写。无需 YAML 解析器,无需网络调用。 - **快速。** 仅构建一次磁盘索引,并在模板更改之前重复使用。 - **可脚本化。** 简洁的可导入 API + `--json` 输出,便于集成到其他工具中。 ## 安装 ``` # 从 GitHub: pip install git+https://github.com/sonnycroco/nuclei-index # 或者从本地 clone: git clone https://github.com/sonnycroco/nuclei-index pip install ./nuclei-index ``` 你还需要一个本地的 nuclei-templates 检出。如果你运行过 nuclei,你就已经有了一个: ``` nuclei -update-templates ``` `nuclei-index` 会按以下顺序查找模板(匹配到第一个即停止): 1. `$NUCLEI_TEMPLATES` 2. `~/nuclei-templates` 3. `~/.local/nuclei-templates` 4. `~/.config/nuclei/templates` ## 用法 ``` # 查找 CVE 并获取要运行的命令 $ nuclei-index --cve CVE-2021-44228 --host https://target.example [CVE-2021-44228] 2 template(s): - CVE-2021-44228 (critical) Apache Log4j RCE (Log4Shell) /home/you/nuclei-templates/http/cves/2021/CVE-2021-44228.yaml - ... Run (rate-limited, authorized hosts only): nuclei -id CVE-2021-44228 -u https://target.example -rl 20 -timeout 10 # 输出 `nuclei -t ` 格式(更快 — 跳过加载整个 template set) $ nuclei-index --cve CVE-2021-44228 --host https://target.example --by-path # 机器可读 $ nuclei-index --cve CVE-2021-44228 --json {"cve": "CVE-2021-44228", "templates": [...], "commands": [...]} # 索引统计 / 强制重建 $ nuclei-index --stats $ nuclei-index --rebuild ``` 索引缓存在 `$XDG_CACHE_HOME/nuclei-index/`(默认为 `~/.cache/nuclei-index/`),并在任何 `cves/` 目录下添加或删除 CVE 模板时自动刷新。新鲜度检查是对这些目录的轻量级信号探测——包括它们的修改时间和年份子目录列表——因此干净的运行过程无需为了确认缓存是否最新而重新扫描每个模板。它自身无法察觉两种情况:对现有模板的就地编辑(文件名和目录未更改),或者放置在 `cves/` 目录之外的 CVE 模板。在这些情况下,请运行 `--rebuild` 强制进行全量重新扫描。 ## 作为库使用 ``` import nuclei_index as ni ni.templates_for_cve("CVE-2021-44228") # [{'cve': 'CVE-2021-44228', 'id': 'CVE-2021-44228', # 'path': 'http/cves/2021/CVE-2021-44228.yaml', # 'name': 'Apache Log4j RCE', 'severity': 'critical', # 'suspicious': False}, ...] ni.runnable_cmd("CVE-2021-44228", "https://target.example", rate=20) # 'nuclei -id CVE-2021-44228 -u https://target.example -rl 20 -timeout 10' ni.runnable_cmds("CVE-2021-44228", "https://target.example") # every match ``` CVE 的模板将按最高严重性优先返回;`runnable_cmd` 会选取最顶部的那个,而 `runnable_cmds` 则返回全部模板。 ## 负责任的使用 此工具仅*构建*命令——它本身不进行任何扫描。生成的 `nuclei` 命令默认已开启限速。**请仅对你获得授权测试的主机运行这些命令。** ## 开发 ``` pip install -e ".[dev]" pytest ``` 测试套件会构建一个一次性的模拟模板树——它既不需要真实的 nuclei 安装,也不需要你的模板。 ## 许可证 [Apache-2.0](LICENSE)。
标签:CISA项目, Google, Maven, Nuclei, Python, 动态分析, 无后门, 漏洞验证, 逆向工具