aboutsummaryrefslogtreecommitdiffstats
path: root/src/process-request.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/process-request.php')
-rw-r--r--src/process-request.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/process-request.php b/src/process-request.php
index 9c6a006..fd290ce 100644
--- a/src/process-request.php
+++ b/src/process-request.php
@@ -5,6 +5,8 @@
//
// SPDX-License-Identifier: AGPL-3.0-or-later
+use VolseNet\Webtrap\XmlRpcMethod;
+
$data = [
'SERVER_NAME' => $_SERVER['SERVER_NAME'],
'REMOTE_ADDR' => $_SERVER['REMOTE_ADDR'],
@@ -19,7 +21,21 @@ $data = [
'BODY' => file_get_contents('php://input'),
];
+if (preg_match('/xmlrpc\.php/i', $data['REQUEST_URI']) && $data['REQUEST_METHOD'] === 'POST') {
+ $method = XmlRpcMethod::parse($data['BODY']);
+ if ($method->name === 'wp.getUsersBlogs') {
+ $file_name = dirname(__DIR__) . '/payloads/credentials.txt';
+ $file = new SplFileObject($file_name, 'a');
+ $file->fwrite("{$method->params[0]}: {$method->params[1]}\n");
+ error_log("Trapped XML-RPC request, saving credentials to {$file_name}");
+
+ header("HTTP/1.1 404 Not Found");
+ die();
+ }
+}
+
$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");