From 27bf644d5809be63e439484a3f8ffee81b9d367b Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Thu, 4 Jul 2024 13:02:59 +0200 Subject: Rename trap-post-payload.php and call it from index.php. --- index.php | 3 +++ src/process-request.php | 25 +++++++++++++++++++++++++ trap-post-payload.php | 25 ------------------------- 3 files changed, 28 insertions(+), 25 deletions(-) create mode 100644 src/process-request.php delete mode 100644 trap-post-payload.php diff --git a/index.php b/index.php index efed2bf..cbe3802 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,7 @@ + $_SERVER['SERVER_NAME'], + 'REMOTE_ADDR' => $_SERVER['REMOTE_ADDR'], + 'REMOTE_PORT' => $_SERVER['REMOTE_PORT'], + 'REQUEST_METHOD' => $_SERVER['REQUEST_METHOD'], + 'REQUEST_URI' => $_SERVER['REQUEST_URI'], + 'QUERY_STRING' => $_SERVER['QUERY_STRING'], + 'REQUEST_TIME' => $_SERVER['REQUEST_TIME'], + 'REQUEST_HEADERS' => getallheaders(), + 'POST' => $_POST, + 'COOKIES' => $_COOKIE, + 'BODY' => file_get_contents('php://input'), +]; + +$file_name = dirname(__DIR__) . "/payloads/{$data['REQUEST_TIME']}-{$data['SERVER_NAME']}.json"; +error_log("Trapped request, saving to {$file_name}"); +file_put_contents($file_name, json_encode($data)); +header("HTTP/1.1 404 Not Found"); diff --git a/trap-post-payload.php b/trap-post-payload.php deleted file mode 100644 index 4316ff1..0000000 --- a/trap-post-payload.php +++ /dev/null @@ -1,25 +0,0 @@ - $_SERVER['SERVER_NAME'], - 'REMOTE_ADDR' => $_SERVER['REMOTE_ADDR'], - 'REMOTE_PORT' => $_SERVER['REMOTE_PORT'], - 'REQUEST_METHOD' => $_SERVER['REQUEST_METHOD'], - 'REQUEST_URI' => $_SERVER['REQUEST_URI'], - 'QUERY_STRING' => $_SERVER['QUERY_STRING'], - 'REQUEST_TIME' => $_SERVER['REQUEST_TIME'], - 'REQUEST_HEADERS' => getallheaders(), - 'POST' => $_POST, - 'COOKIES' => $_COOKIE, - 'BODY' => file_get_contents('php://input'), -]; - -$file_name = __DIR__ . "/payloads/{$data['REQUEST_TIME']}-{$data['SERVER_NAME']}.json"; -error_log("Trapped request, saving to {$file_name}"); -file_put_contents($file_name, json_encode($data)); -header("HTTP/1.1 404 Not Found"); -- cgit v1.2.3