Skip to content

Commit 1c73c19

Browse files
committed
Add machine_id support to windows php meterp
1 parent 10bd753 commit 1c73c19

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

data/meterpreter/meterpreter.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -449,13 +449,10 @@ function core_machine_id($req, &$pkt) {
449449
$serial = "";
450450

451451
if (is_windows()) {
452-
# TODO: need help from real PHP folks who know how to do
453-
# things via the Windows API. We need to:
454-
# 1) get the system volume
455-
# 2) get the volume information for that volume.
456-
# 3) get the serial number from the extracted volume info.
457-
# 4) create a serial in the format:
458-
# "{0:04x}-{1:04x}".format((serial_num >> 16) & 0xFFFF, serial_num & 0xFFFF)
452+
# It's dirty, but there's not really a nicer way of doing this on windows. Make sure
453+
# it's lowercase as this is what the other meterpreters use.
454+
$output = strtolower(shell_exec("vol %SYSTEMDRIVE%"));
455+
$serial = preg_replace('/.*serial number is ([a-z0-9]{4}-[a-z0-9]{4}).*/s', '$1', $output);
459456
} else {
460457
$serial = get_hdd_label();
461458
}

lib/rex/post/meterpreter/client_core.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,11 @@ def machine_id(timeout=nil)
317317
response = client.send_request(*args)
318318

319319
mid = response.get_tlv_value(TLV_TYPE_MACHINE_ID)
320+
321+
# Normalise the format of the incoming machine id so that it's consistent
322+
# regardless of case and leading/trailing spaces. This means that the
323+
# individual meterpreters don't have to care
324+
mid.downcase!.strip! if mid
320325
return Rex::Text.md5(mid)
321326
end
322327

modules/payloads/singles/php/meterpreter_reverse_tcp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
module Metasploit4
1414

15-
CachedSize = 25532
15+
CachedSize = 25679
1616

1717
include Msf::Payload::Single
1818
include Msf::Payload::Php::ReverseTcp

0 commit comments

Comments
 (0)