From 7f21e9a29b46ee4d2c15ce413a33640f4c26987c Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sun, 1 Sep 2024 22:26:31 +0200 Subject: [PATCH] Add a fallback to get the hostname --- php/meterpreter/meterpreter.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/php/meterpreter/meterpreter.php b/php/meterpreter/meterpreter.php index f0d43528..b42d945d 100755 --- a/php/meterpreter/meterpreter.php +++ b/php/meterpreter/meterpreter.php @@ -670,12 +670,15 @@ if (!function_exists('core_machine_id')) { register_command('core_machine_id', COMMAND_ID_CORE_MACHINE_ID); function core_machine_id($req, &$pkt) { my_print("doing core_machine_id"); - if (is_callable('gethostname')) { + if (can_call_function('gethostname')) { # introduced in 5.3 $machine_id = gethostname(); - } else { + } elseif(can_call_function('php_uname')) { $machine_id = php_uname('n'); } + } else { + $machine_id = getenv('HOSTNAME'); + } $serial = ""; if (is_windows()) {