1
mirror of https://github.com/rapid7/metasploit-payloads synced 2024-11-26 17:41:08 +01:00

Land #559, Add logging prerequisites to PHP Meterpreter

This commit is contained in:
adfoster-r7 2022-04-12 17:16:19 +01:00 committed by GitHub
commit 65d4185a8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,8 +42,31 @@ function register_command($c, $i) {
}
}
# Debugging payload definitions
define("MY_DEBUGGING", false);
define("MY_DEBUGGING_LOG_FILE_PATH", false);
function my_logfile($str) {
if (MY_DEBUGGING && MY_DEBUGGING_LOG_FILE_PATH) {
if (!isset($GLOBALS['logfile'])) {
$GLOBALS['logfile'] = fopen(MY_DEBUGGING_LOG_FILE_PATH, 'a');
if (!$GLOBALS['logfile']) {
my_print("Failed to open debug log file");
}
}
if ($GLOBALS['logfile']) {
fwrite($GLOBALS['logfile'], "$str\n");
}
}
}
function my_print($str) {
#error_log($str);
if (MY_DEBUGGING) {
error_log($str);
my_logfile($str);
}
}
my_print("Evaling main meterpreter stage");
@ -1411,11 +1434,13 @@ function remove_reader($resource) {
ob_implicit_flush();
# For debugging
#error_reporting(E_ALL);
# Turn off error reporting so we don't leave any ugly logs. Why make an
# administrator's job easier if we don't have to? =)
error_reporting(0);
if (MY_DEBUGGING) {
error_reporting(E_ALL);
} else {
error_reporting(0);
}
@ignore_user_abort(true);
# Has no effect in safe mode, but try anyway