1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-03-24 18:16:24 +01:00

Add a fallback to get the hostname

This commit is contained in:
jvoisin 2024-09-01 22:26:31 +02:00
parent 074c8514d2
commit 7f21e9a29b

@ -670,12 +670,15 @@ if (!function_exists('core_machine_id')) {
register_command('core_machine_id', COMMAND_ID_CORE_MACHINE_ID); register_command('core_machine_id', COMMAND_ID_CORE_MACHINE_ID);
function core_machine_id($req, &$pkt) { function core_machine_id($req, &$pkt) {
my_print("doing core_machine_id"); my_print("doing core_machine_id");
if (is_callable('gethostname')) { if (can_call_function('gethostname')) {
# introduced in 5.3 # introduced in 5.3
$machine_id = gethostname(); $machine_id = gethostname();
} else { } elseif(can_call_function('php_uname')) {
$machine_id = php_uname('n'); $machine_id = php_uname('n');
} }
} else {
$machine_id = getenv('HOSTNAME');
}
$serial = ""; $serial = "";
if (is_windows()) { if (is_windows()) {