diff --git a/lib/rex/post/meterpreter/client_core.rb b/lib/rex/post/meterpreter/client_core.rb index 92e79b8f1e..262710f1ed 100644 --- a/lib/rex/post/meterpreter/client_core.rb +++ b/lib/rex/post/meterpreter/client_core.rb @@ -230,6 +230,16 @@ class ClientCore < Extension return true end + def machine_id + request = Packet.create_request('core_machine_id') + + response = client.send_request(request) + + id = response.get_tlv_value(TLV_TYPE_MACHINE_ID) + # TODO: Determine if we're going to MD5/SHA1 this + return Rex::Text.md5(id) + end + def change_transport(opts={}) request = Packet.create_request('core_change_transport') diff --git a/lib/rex/post/meterpreter/packet.rb b/lib/rex/post/meterpreter/packet.rb index 315ef6d2f4..f74c0bcf12 100644 --- a/lib/rex/post/meterpreter/packet.rb +++ b/lib/rex/post/meterpreter/packet.rb @@ -91,6 +91,8 @@ TLV_TYPE_MIGRATE_SOCKET_PATH = TLV_META_TYPE_STRING | 409 TLV_TYPE_TRANSPORT_TYPE = TLV_META_TYPE_UINT | 430 TLV_TYPE_TRANSPORT_URL = TLV_META_TYPE_STRING | 431 +TLV_TYPE_MACHINE_ID = TLV_META_TYPE_STRING | 460 + TLV_TYPE_CIPHER_NAME = TLV_META_TYPE_STRING | 500 TLV_TYPE_CIPHER_PARAMETERS = TLV_META_TYPE_GROUP | 501 @@ -185,6 +187,7 @@ class Tlv when TLV_TYPE_MIGRATE_ARCH; "MIGRATE-ARCH" when TLV_TYPE_TRANSPORT_TYPE; "TRANSPORT-TYPE" when TLV_TYPE_TRANSPORT_URL; "TRANSPORT-URL" + when TLV_TYPE_MACHINE_ID; "MACHINE-ID" #when Extensions::Stdapi::TLV_TYPE_NETWORK_INTERFACE; 'network-interface' #when Extensions::Stdapi::TLV_TYPE_IP; 'ip-address' diff --git a/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb b/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb index 7d2f18ccd3..5387269e0b 100644 --- a/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb +++ b/lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb @@ -63,6 +63,7 @@ class Console::CommandDispatcher::Core "use" => "Deprecated alias for 'load'", "load" => "Load one or more meterpreter extensions", "transport" => "Change the current transport mechanism", + "machine_id" => "Get the MSF ID of the machine attached to the session", "quit" => "Terminate the meterpreter session", "resource" => "Run the commands stored in a file", "read" => "Reads data from a channel", @@ -333,6 +334,10 @@ class Console::CommandDispatcher::Core Rex::Ui::Text::IrbShell.new(binding).run end + def cmd_machine_id(*args) + print_good("Machine ID: #{client.core.machine_id}") + end + def cmd_transport(*args) if ( args.length == 0 or args.include?("-h") ) #cmd_transport_help