Skip to content

Commit a0bcbd1

Browse files
committed
Merge branch 'master' of github.com:rapid7/metasploit-framework
2 parents f6a8982 + 74ea85f commit a0bcbd1

File tree

109 files changed

+2720
-773
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+2720
-773
lines changed

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PATH
99
json
1010
metasploit-concern (~> 1.0)
1111
metasploit-model (~> 1.0)
12-
metasploit-payloads (= 0.0.7)
12+
metasploit-payloads (= 1.0.1)
1313
msgpack
1414
nokogiri
1515
packetfu (= 1.1.9)
@@ -123,7 +123,7 @@ GEM
123123
activemodel (>= 4.0.9, < 4.1.0)
124124
activesupport (>= 4.0.9, < 4.1.0)
125125
railties (>= 4.0.9, < 4.1.0)
126-
metasploit-payloads (0.0.7)
126+
metasploit-payloads (1.0.1)
127127
metasploit_data_models (1.1.0)
128128
activerecord (>= 4.0.9, < 4.1.0)
129129
activesupport (>= 4.0.9, < 4.1.0)

data/meterpreter/meterpreter.php

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#<?php
1+
//<?php
22

33
# Everything that needs to be global has to be made so explicitly so we can run
44
# inside a call to create_user_func($user_input);
@@ -32,7 +32,7 @@
3232

3333
# global list of extension commands
3434
if (!isset($GLOBALS['commands'])) {
35-
$GLOBALS['commands'] = array("core_loadlib");
35+
$GLOBALS['commands'] = array("core_loadlib", "core_machine_id", "core_uuid");
3636
}
3737

3838
function register_command($c) {
@@ -99,18 +99,21 @@ function socket_set_option($sock, $type, $opt, $value) {
9999
}
100100
}
101101

102+
#
103+
# Payload definitions
104+
#
105+
define("PAYLOAD_UUID", "");
102106

103107
#
104108
# Constants
105109
#
106-
define("PACKET_TYPE_REQUEST",0);
107-
define("PACKET_TYPE_RESPONSE",1);
108-
define("PACKET_TYPE_PLAIN_REQUEST", 10);
110+
define("PACKET_TYPE_REQUEST", 0);
111+
define("PACKET_TYPE_RESPONSE", 1);
112+
define("PACKET_TYPE_PLAIN_REQUEST", 10);
109113
define("PACKET_TYPE_PLAIN_RESPONSE", 11);
110114

111-
define("ERROR_SUCCESS",0);
112-
# not defined in original C implementation
113-
define("ERROR_FAILURE",1);
115+
define("ERROR_SUCCESS", 0);
116+
define("ERROR_FAILURE", 1);
114117

115118
define("CHANNEL_CLASS_BUFFERED", 0);
116119
define("CHANNEL_CLASS_STREAM", 1);
@@ -175,6 +178,9 @@ function socket_set_option($sock, $type, $opt, $value) {
175178
define("TLV_TYPE_MIGRATE_PID", TLV_META_TYPE_UINT | 402);
176179
define("TLV_TYPE_MIGRATE_LEN", TLV_META_TYPE_UINT | 403);
177180

181+
define("TLV_TYPE_MACHINE_ID", TLV_META_TYPE_STRING | 460);
182+
define("TLV_TYPE_UUID", TLV_META_TYPE_RAW | 461);
183+
178184
define("TLV_TYPE_CIPHER_NAME", TLV_META_TYPE_STRING | 500);
179185
define("TLV_TYPE_CIPHER_PARAMETERS", TLV_META_TYPE_GROUP | 501);
180186

@@ -419,8 +425,41 @@ function core_loadlib($req, &$pkt) {
419425
}
420426

421427

428+
function core_uuid($req, &$pkt) {
429+
my_print("doing core_uuid");
430+
packet_add_tlv($pkt, create_tlv(TLV_TYPE_UUID, PAYLOAD_UUID));
431+
return ERROR_SUCCESS;
432+
}
422433

423434

435+
function get_hdd_label() {
436+
foreach (scandir('/dev/disk/by-id/') as $file) {
437+
foreach (array("ata-", "mb-") as $prefix) {
438+
if (strpos($file, $prefix) === 0) {
439+
return substr($file, strlen($prefix));
440+
}
441+
}
442+
}
443+
return "";
444+
}
445+
446+
function core_machine_id($req, &$pkt) {
447+
my_print("doing core_machine_id");
448+
$machine_id = gethostname();
449+
$serial = "";
450+
451+
if (is_windows()) {
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);
456+
} else {
457+
$serial = get_hdd_label();
458+
}
459+
460+
packet_add_tlv($pkt, create_tlv(TLV_TYPE_MACHINE_ID, $serial.":".$machine_id));
461+
return ERROR_SUCCESS;
462+
}
424463

425464

426465
##

data/meterpreter/meterpreter.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
HTTP_EXPIRATION_TIMEOUT = 604800
6868
HTTP_PROXY = None
6969
HTTP_USER_AGENT = None
70+
PAYLOAD_UUID = ""
7071

7172
PACKET_TYPE_REQUEST = 0
7273
PACKET_TYPE_RESPONSE = 1
@@ -144,6 +145,7 @@
144145
TLV_TYPE_MIGRATE_LEN = TLV_META_TYPE_UINT | 403
145146

146147
TLV_TYPE_MACHINE_ID = TLV_META_TYPE_STRING | 460
148+
TLV_TYPE_UUID = TLV_META_TYPE_RAW | 461
147149

148150
TLV_TYPE_CIPHER_NAME = TLV_META_TYPE_STRING | 500
149151
TLV_TYPE_CIPHER_PARAMETERS = TLV_META_TYPE_GROUP | 501
@@ -570,7 +572,19 @@ def handle_dead_resource_channel(self, channel_id):
570572
pkt = struct.pack('>I', len(pkt) + 4) + pkt
571573
self.send_packet(pkt)
572574

575+
def _core_uuid(self, request, response):
576+
response += tlv_pack(TLV_TYPE_UUID, PAYLOAD_UUID)
577+
return ERROR_SUCCESS, response
578+
573579
def _core_machine_id(self, request, response):
580+
def get_hdd_label():
581+
for _, _, files in os.walk('/dev/disk/by-id/'):
582+
for f in files:
583+
for p in ['ata-', 'mb-']:
584+
if f[:len(p)] == p:
585+
return f[len(p):]
586+
return ""
587+
574588
serial = ''
575589
machine_name = platform.uname()[1]
576590
if has_windll:
@@ -592,11 +606,8 @@ def _core_machine_id(self, request, response):
592606
serial_num = serial_num.value
593607
serial = "{0:04x}-{1:04x}".format((serial_num >> 16) & 0xFFFF, serial_num & 0xFFFF)
594608
else:
595-
for _, _, files in os.walk('/dev/disk/by-id/'):
596-
for f in files:
597-
if f[:4] == 'ata-':
598-
serial = f[4:]
599-
break
609+
serial = get_hdd_label()
610+
600611
response += tlv_pack(TLV_TYPE_MACHINE_ID, "%s:%s" % (serial, machine_name))
601612
return ERROR_SUCCESS, response
602613

data/php/bind_tcp.php

Lines changed: 0 additions & 56 deletions
This file was deleted.

data/php/bind_tcp_ipv6.php

Lines changed: 0 additions & 53 deletions
This file was deleted.

data/php/reverse_tcp.php

Lines changed: 0 additions & 56 deletions
This file was deleted.

lib/msf/base/serializer/readable_text.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,11 @@ def self.dump_sessions_verbose(framework, opts={})
589589
sess_via = session.via_exploit.to_s
590590
sess_type = session.type.to_s
591591
sess_uuid = session.payload_uuid.to_s
592+
sess_puid = session.payload_uuid.respond_to?(:puid_hex) ? session.payload_uuid.puid_hex : nil
593+
592594
sess_checkin = "<none>"
593595
sess_machine_id = session.machine_id.to_s
596+
sess_registration = "No"
594597

595598
if session.respond_to? :platform
596599
sess_type << (" " + session.platform)
@@ -600,6 +603,13 @@ def self.dump_sessions_verbose(framework, opts={})
600603
sess_checkin = "#{(Time.now.to_i - session.last_checkin.to_i)}s ago @ #{session.last_checkin.to_s}"
601604
end
602605

606+
if session.payload_uuid.respond_to?(:puid_hex) && (uuid_info = framework.uuid_db[sess_puid])
607+
sess_registration = "Yes"
608+
if uuid_info['name']
609+
sess_registration << " - Name=\"#{uuid_info['name']}\""
610+
end
611+
end
612+
603613
out << " Session ID: #{sess_id}\n"
604614
out << " Type: #{sess_type}\n"
605615
out << " Info: #{sess_info}\n"
@@ -608,6 +618,10 @@ def self.dump_sessions_verbose(framework, opts={})
608618
out << " UUID: #{sess_uuid}\n"
609619
out << " MachineID: #{sess_machine_id}\n"
610620
out << " CheckIn: #{sess_checkin}\n"
621+
out << " Registered: #{sess_registration}\n"
622+
623+
624+
611625
out << "\n"
612626
end
613627

0 commit comments

Comments
 (0)