Exploit databaseDownload repository ZIP
GH-13475eca32827b371d9b1c61e38dfde3
neldi24git/php2shell-lab
Sources for CVE-2026-109618
413 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files5
neldi24git/php2shell-labRevision 87c0d0efb884
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
php2shell_lab/probe.py
Python · 11,405 bytes"""Non-destructive exposure probe for CVE-2026-109618 / CVE-2026-109619.
The probe answers two questions about a host, and nothing more:
1. Which PHP version is serving HTTP, and is it below a fixed release?
2. Is ``session.upload_progress`` reachable, i.e. is the precondition for the
CVE-2026-109619 upload path present?
It never sends an oversized body and never attempts to trigger the
out-of-memory condition. See ``repro.py`` for the lab-only availability
harness.
"""
from __future__ import annotations
import argparse
import http.client
import json
import secrets
import socket
import ssl
import sys
import urllib.parse
from dataclasses import asdict, dataclass, field
from typing import Dict, List, Optional, Tuple
from . import versions
from .versions import Classification
MAX_BODY = 64 * 1024
DEFAULT_TIMEOUT = 8.0
#: Headers that may disclose the interpreter version, in priority order.
VERSION_HEADERS: Tuple[str, ...] = (
"x-powered-by",
"x-php-version",
"server",
"x-backend-server",
)
LOOPBACK_HOSTS = {"127.0.0.1", "::1", "localhost"}
@dataclass
class Target:
scheme: str
host: str
port: int
path: str = "/"
@property
def url(self) -> str:
default = 443 if self.scheme == "https" else 80
netloc = self.host if self.port == default else f"{self.host}:{self.port}"
return f"{self.scheme}://{netloc}{self.path}"
@dataclass
class Finding:
target: str
reachable: bool = False
error: Optional[str] = None
server: Optional[str] = None
powered_by: Optional[str] = None
php_version: Optional[str] = None
classification: Optional[str] = None
fixed_in: Optional[str] = None
upload_progress: Optional[bool] = None
notes: List[str] = field(default_factory=list)
@property
def affected(self) -> bool:
return self.classification in (versions.AFFECTED, versions.AFFECTED_EOL)
def to_dict(self) -> Dict[str, object]:
data = asdict(self)
data["affected"] = self.affected
return data
def parse_target(raw: str) -> Target:
"""Parse ``host``, ``host:port`` or a full URL into a :class:`Target`."""
if "://" not in raw:
raw = "http://" + raw
parts = urllib.parse.urlsplit(raw)
if parts.scheme not in ("http", "https"):
raise ValueError(f"unsupported scheme: {parts.scheme!r}")
if not parts.hostname:
raise ValueError(f"could not parse a hostname from {raw!r}")
scheme = parts.scheme
default_port = 443 if scheme == "https" else 80
port = parts.port or default_port
path = parts.path or "/"
if parts.query:
path = f"{path}?{parts.query}"
return Target(scheme=scheme, host=parts.hostname, port=port, path=path)
def is_loopback(host: str) -> bool:
if host in LOOPBACK_HOSTS:
return True
return host.startswith("127.") or host == "::1"
def _request(
target: Target,
method: str = "GET",
body: Optional[bytes] = None,
headers: Optional[Dict[str, str]] = None,
timeout: float = DEFAULT_TIMEOUT,
) -> Tuple[int, str, List[Tuple[str, str]], bytes]:
if target.scheme == "https":
context = ssl.create_default_context()
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
conn: http.client.HTTPConnection = http.client.HTTPSConnection(
target.host, target.port, timeout=timeout, context=context
)
else:
conn = http.client.HTTPConnection(target.host, target.port, timeout=timeout)
try:
conn.request(method, target.path, body=body, headers=headers or {})
response = conn.getresponse()
payload = response.read(MAX_BODY)
return response.status, response.reason, response.getheaders(), payload
finally:
conn.close()
def _header_map(headers: List[Tuple[str, str]]) -> Dict[str, List[str]]:
out: Dict[str, List[str]] = {}
for name, value in headers:
out.setdefault(name.lower(), []).append(value)
return out
def _upload_progress_body() -> Tuple[str, bytes]:
"""Build a minimal, harmless multipart body that exercises upload progress."""
boundary = "----php2shell-probe-" + secrets.token_hex(8)
token = secrets.token_hex(8)
chunks = [
f"--{boundary}\r\n"
f'Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS"\r\n\r\n'
f"{token}\r\n",
f"--{boundary}\r\n"
f'Content-Disposition: form-data; name="file"; filename="probe.txt"\r\n'
f"Content-Type: text/plain\r\n\r\nprobe\r\n",
f"--{boundary}--\r\n",
]
return boundary, "".join(chunks).encode("ascii")
def check_upload_progress(target: Target, timeout: float = DEFAULT_TIMEOUT) -> Optional[bool]:
"""Return True if PHP answered with a ``PHPSESSID`` cookie.
``session.upload_progress.enabled`` is on by default and the progress
handler runs before application code, even when the script never calls
``session_start()``. A ``PHPSESSID`` cookie therefore indicates the
precondition for the CVE-2026-109619 upload path.
Side effect: an empty session record may be created on the target. That is
the only state change this probe makes.
"""
boundary, body = _upload_progress_body()
headers = {
"Content-Type": f"multipart/form-data; boundary={boundary}",
"Content-Length": str(len(body)),
"User-Agent": "php2shell-lab/probe",
}
try:
status, _reason, response_headers, _payload = _request(
target, "POST", body=body, headers=headers, timeout=timeout
)
except (OSError, http.client.HTTPException):
return None
if status in (403, 405, 413, 415, 501):
return None
cookies = _header_map(response_headers).get("set-cookie", [])
return any("PHPSESSID" in cookie for cookie in cookies)
def probe(raw_target: str, timeout: float = DEFAULT_TIMEOUT, check_progress: bool = True) -> Finding:
target = parse_target(raw_target)
finding = Finding(target=target.url)
try:
status, reason, headers, _payload = _request(target, timeout=timeout)
except socket.timeout:
finding.error = f"timed out after {timeout:g}s"
return finding
except (OSError, http.client.HTTPException) as exc:
finding.error = f"{type(exc).__name__}: {exc}"
return finding
finding.reachable = True
header_map = _header_map(headers)
def first(name: str) -> Optional[str]:
values = header_map.get(name)
return values[0] if values else None
finding.server = first("server")
finding.powered_by = first("x-powered-by")
for name in VERSION_HEADERS:
value = first(name)
if not value:
continue
parsed = versions.parse_version(value)
if parsed is not None:
finding.php_version = ".".join(str(part) for part in parsed)
break
classification: Classification = versions.classify(
versions.parse_version(finding.php_version) if finding.php_version else None
)
finding.classification = classification.status
if classification.fixed_in:
finding.fixed_in = ".".join(str(part) for part in classification.fixed_in)
finding.notes.append(classification.detail)
if finding.php_version is None:
finding.notes.append(
"no PHP version in response headers; expose_php is likely off. "
"Check the package version on the host instead."
)
if finding.reachable and status >= 400:
finding.notes.append(f"root request returned HTTP {status} {reason}")
if check_progress:
finding.upload_progress = check_upload_progress(target, timeout=timeout)
if finding.upload_progress is False:
finding.notes.append("no PHPSESSID issued; upload progress may be disabled or blocked")
elif finding.upload_progress is None:
finding.notes.append("upload-progress probe inconclusive (blocked or unsupported)")
return finding
def _format(finding: Finding) -> str:
status_labels = {
versions.NOT_AFFECTED: "NOT AFFECTED",
versions.FIXED: "FIXED",
versions.AFFECTED: "AFFECTED",
versions.AFFECTED_EOL: "AFFECTED (EOL branch)",
versions.UNKNOWN: "UNKNOWN",
}
rows = [("target", finding.target), ("reachable", "yes" if finding.reachable else "no")]
if finding.error:
rows.append(("error", finding.error))
if finding.server:
rows.append(("server", finding.server))
if finding.powered_by:
rows.append(("x-powered-by", finding.powered_by))
rows.append(("php version", finding.php_version or "unknown"))
rows.append(("cve status", status_labels.get(finding.classification or "", "UNKNOWN")))
if finding.fixed_in:
rows.append(("fixed in", finding.fixed_in))
if finding.upload_progress is not None:
rows.append(("upload progress", "enabled" if finding.upload_progress else "not observed"))
width = max(len(name) for name, _ in rows) + 2
lines = [f"{name.ljust(width)}{value}" for name, value in rows]
for note in finding.notes:
lines.append(f"{'note'.ljust(width)}{note}")
return "\n".join(lines)
def build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
prog="php2shell-probe",
description=(
"Non-destructive exposure probe for CVE-2026-109618 / CVE-2026-109619. "
"Reads response headers, never triggers memory exhaustion."
),
)
parser.add_argument("targets", nargs="+", metavar="TARGET", help="host, host:port or URL")
parser.add_argument("--timeout", type=float, default=DEFAULT_TIMEOUT, help="per-request timeout")
parser.add_argument(
"--no-upload-progress",
action="store_true",
help="skip the session.upload_progress check (it may create an empty session)",
)
parser.add_argument("--json", action="store_true", help="emit machine-readable JSON")
parser.add_argument(
"--allow-remote",
action="store_true",
help="permit probing non-loopback hosts; only use this on hosts you are authorised to test",
)
return parser
def main(argv: Optional[List[str]] = None) -> int:
args = build_parser().parse_args(argv)
targets: List[str] = []
for raw in args.targets:
try:
target = parse_target(raw)
except ValueError as exc:
print(f"php2shell-probe: {exc}", file=sys.stderr)
return 2
if not is_loopback(target.host) and not args.allow_remote:
print(
f"php2shell-probe: refusing to probe non-loopback host {target.host!r} "
"without --allow-remote",
file=sys.stderr,
)
return 2
targets.append(raw)
findings = [
probe(raw, timeout=args.timeout, check_progress=not args.no_upload_progress)
for raw in targets
]
if args.json:
print(json.dumps([finding.to_dict() for finding in findings], indent=2))
else:
for index, finding in enumerate(findings):
if index:
print()
print(_format(finding))
return 0 if all(finding.reachable for finding in findings) else 1
if __name__ == "__main__": # pragma: no cover
raise SystemExit(main())