Skip to content

Commit 79ec2e0

Browse files
committed
Add machine ID support to the command list
1 parent c0f4961 commit 79ec2e0

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

lib/rex/post/meterpreter/client_core.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,16 @@ def use(mod, opts = { })
230230
return true
231231
end
232232

233+
def machine_id
234+
request = Packet.create_request('core_machine_id')
235+
236+
response = client.send_request(request)
237+
238+
id = response.get_tlv_value(TLV_TYPE_MACHINE_ID)
239+
# TODO: Determine if we're going to MD5/SHA1 this
240+
return Rex::Text.md5(id)
241+
end
242+
233243
def change_transport(opts={})
234244
request = Packet.create_request('core_change_transport')
235245

lib/rex/post/meterpreter/packet.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ module Meterpreter
9191
TLV_TYPE_TRANSPORT_TYPE = TLV_META_TYPE_UINT | 430
9292
TLV_TYPE_TRANSPORT_URL = TLV_META_TYPE_STRING | 431
9393

94+
TLV_TYPE_MACHINE_ID = TLV_META_TYPE_STRING | 460
95+
9496
TLV_TYPE_CIPHER_NAME = TLV_META_TYPE_STRING | 500
9597
TLV_TYPE_CIPHER_PARAMETERS = TLV_META_TYPE_GROUP | 501
9698

@@ -185,6 +187,7 @@ def inspect
185187
when TLV_TYPE_MIGRATE_ARCH; "MIGRATE-ARCH"
186188
when TLV_TYPE_TRANSPORT_TYPE; "TRANSPORT-TYPE"
187189
when TLV_TYPE_TRANSPORT_URL; "TRANSPORT-URL"
190+
when TLV_TYPE_MACHINE_ID; "MACHINE-ID"
188191

189192
#when Extensions::Stdapi::TLV_TYPE_NETWORK_INTERFACE; 'network-interface'
190193
#when Extensions::Stdapi::TLV_TYPE_IP; 'ip-address'

lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def commands
6363
"use" => "Deprecated alias for 'load'",
6464
"load" => "Load one or more meterpreter extensions",
6565
"transport" => "Change the current transport mechanism",
66+
"machine_id" => "Get the MSF ID of the machine attached to the session",
6667
"quit" => "Terminate the meterpreter session",
6768
"resource" => "Run the commands stored in a file",
6869
"read" => "Reads data from a channel",
@@ -333,6 +334,10 @@ def cmd_irb(*args)
333334
Rex::Ui::Text::IrbShell.new(binding).run
334335
end
335336

337+
def cmd_machine_id(*args)
338+
print_good("Machine ID: #{client.core.machine_id}")
339+
end
340+
336341
def cmd_transport(*args)
337342
if ( args.length == 0 or args.include?("-h") )
338343
#cmd_transport_help

0 commit comments

Comments
 (0)