Exploit databaseDownload repository ZIP
GH-56a5614eca576c08feea4e04aacfa2a2
kipmyk/php2shell
Sources for CVE-2026-109618
411 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files7
kipmyk/php2shellRevision e354452bffba
- ↑..Parent directory
- compare_regression.py
- exploit_chain_poc.py
- reproduce_oom_request_parsing.php
- test_multipart_headers.py
- test_oom.py
- test_upload_progress.py
- test_upload_progress_regression.py
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit_lab/reproduce_oom_request_parsing.php
PHP · 4,866 bytes<?php
/**
* reproduce_oom_request_parsing.php
*
* Standalone reproduction script for the upstream test:
* sapi/cli/tests/oom_request_parsing_next_request.phpt
*
* Checks whether an out-of-memory error during request parsing
* corrupts state or crashes/leaks into the subsequent request
* on a persistent web server process.
*/
class CliServerInfo {
public function __construct(
public string $docRoot,
public $processHandle,
) {}
}
function php_cli_server_start(
?string $code = 'echo "Hello world";',
?string $router = 'index.php',
array $cmd_args = []
): CliServerInfo {
$php_executable = PHP_BINARY;
$doc_root = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'oom_test_' . getmypid();
@mkdir($doc_root);
if ($code) {
file_put_contents($doc_root . '/' . ($router ?: 'index.php'), '<?php ' . $code . ' ?>');
}
$cmd = [$php_executable, '-t', $doc_root, '-n', ...$cmd_args, '-S', '127.0.0.1:0'];
if (!is_null($router)) {
$cmd[] = $router;
}
$output_file = tempnam(sys_get_temp_dir(), 'cli_server_output');
$output_file_fd = fopen($output_file, 'ab');
$descriptorspec = [
0 => STDIN,
1 => $output_file_fd,
2 => $output_file_fd,
];
$handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root, null, ["suppress_errors" => true]);
$bound = null;
for ($i = 0; $i < 60; $i++) {
usleep(50000);
$status = proc_get_status($handle);
if (empty($status['running'])) {
echo "[-] Server failed to start\n";
proc_terminate($handle);
exit(1);
}
$output = file_get_contents($output_file);
if (preg_match('@PHP \S* Development Server \(https?://(.*?:\d+)\) started@', $output, $matches)) {
$bound = $matches[1];
break;
}
}
if ($bound === null) {
echo "[-] Server did not output startup message\n";
proc_terminate($handle);
exit(1);
}
$port = (int) substr($bound, strrpos($bound, ':') + 1);
define("CLI_HOST", "127.0.0.1");
define("CLI_PORT", $port);
return new CliServerInfo($doc_root, $handle);
}
function send_raw_http(string $request): string {
$fp = fsockopen(CLI_HOST, CLI_PORT, $errno, $errstr, 2.0);
if (!$fp) {
return "CONNECT_FAILED: $errstr ($errno)";
}
fwrite($fp, $request);
$response = stream_get_contents($fp);
fclose($fp);
return $response;
}
echo "========================================================\n";
echo "Testing PHP Version: " . PHP_VERSION . " (" . (PHP_ZTS ? "ZTS" : "NTS") . ")\n";
echo "========================================================\n";
$server = php_cli_server_start(<<<'PHP'
spl_autoload_register(function ($class) {
eval("class $class {}");
});
ob_start();
echo get_class(new Foo), "\n";
trigger_error("Bar", E_USER_WARNING);
ob_end_flush();
PHP, 'index.php', ['-d', 'memory_limit=8M', '-d', 'post_max_size=64M', '-d', 'html_errors=0']);
echo "[+] CLI Server started on " . CLI_HOST . ":" . CLI_PORT . "\n";
// Request 1: POST payload exceeding 8M memory limit
echo "[*] Step 1: Sending 6MB payload to exceed memory_limit=8M...\n";
$body = 'a=' . str_repeat('a', 6 * 1024 * 1024);
$post_req = "POST / HTTP/1.1\r\nHost: 127.0.0.1\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: " . strlen($body) . "\r\nConnection: keep-alive\r\n\r\n" . $body;
$t0 = microtime(true);
$resp1 = send_raw_http($post_req);
$dt1 = microtime(true) - t0;
$oom_triggered = str_contains($resp1, 'Allowed memory size of 8388608 bytes exhausted');
echo "[+] Step 1 OOM Triggered: " . ($oom_triggered ? "YES (Expected)" : "NO") . "\n";
$first_line = strtok($resp1, "\r\n");
echo " Response Status: $first_line\n";
if (!$oom_triggered) {
echo " Snippet: " . substr($resp1, 0, 200) . "\n";
}
// Check server status
$status = proc_get_status($server->processHandle);
echo "[*] Server process running after OOM request: " . ($status['running'] ? "YES" : "NO (Crashed/Terminated with exit code " . $status['exitcode'] . ")") . "\n";
// Request 2: Normal GET request on the same server
echo "\n[*] Step 2: Sending sequential GET request to check state leakage/survival...\n";
$get_req = "GET / HTTP/1.1\r\nHost: 127.0.0.1\r\nConnection: close\r\n\r\n";
$resp2 = send_raw_http($get_req);
$body2 = substr($resp2, strpos($resp2, "\r\n\r\n") + 4);
echo "[+] Step 2 Response Body:\n$body2\n";
$expected_prefix = "Foo\n\nWarning: Bar";
if (str_starts_with(trim($body2), "Foo")) {
echo "[+] SUCCESS: Worker successfully served next request without corruption.\n";
} else {
echo "[-] DIVERGENCE / FAILURE: Next request returned unexpected output or failed.\n";
}
proc_terminate($server->processHandle);
echo "========================================================\n\n";