Skip to content

Commit 705d150

Browse files
author
Brent Cook
committed
Land rapid7#7396, Add Meterpreter API to list installed drivers
2 parents 6ac63f0 + 55d2677 commit 705d150

File tree

5 files changed

+41
-11
lines changed

5 files changed

+41
-11
lines changed

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ PATH
1414
metasploit-concern
1515
metasploit-credential
1616
metasploit-model
17-
metasploit-payloads (= 1.1.16)
17+
metasploit-payloads (= 1.1.19)
1818
metasploit_data_models
1919
metasploit_payloads-mettle (= 0.0.6)
2020
msgpack
@@ -167,7 +167,7 @@ GEM
167167
activemodel (~> 4.2.6)
168168
activesupport (~> 4.2.6)
169169
railties (~> 4.2.6)
170-
metasploit-payloads (1.1.16)
170+
metasploit-payloads (1.1.19)
171171
metasploit_data_models (2.0.4)
172172
activerecord (~> 4.2.6)
173173
activesupport (~> 4.2.6)

lib/rex/post/meterpreter/extensions/stdapi/sys/config.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,25 @@ def is_system?
5151
getsid == SYSTEM_SID
5252
end
5353

54+
#
55+
# Returns a list of currently active drivers used by the target system
56+
#
57+
def getdrivers
58+
request = Packet.create_request('stdapi_sys_config_driver_list')
59+
response = client.send_request(request)
60+
61+
result = []
62+
63+
response.each(TLV_TYPE_DRIVER_ENTRY) do |driver|
64+
result << {
65+
basename: driver.get_tlv_value(TLV_TYPE_DRIVER_BASENAME),
66+
filename: driver.get_tlv_value(TLV_TYPE_DRIVER_FILENAME)
67+
}
68+
end
69+
70+
result
71+
end
72+
5473
#
5574
# Returns a hash of requested environment variables, along with their values.
5675
# If a requested value doesn't exist in the response, then the value wasn't found.

lib/rex/post/meterpreter/extensions/stdapi/tlv.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ module Stdapi
158158
TLV_TYPE_PROCESS_SESSION = TLV_META_TYPE_UINT | 2308
159159
TLV_TYPE_PROCESS_ARCH_NAME = TLV_META_TYPE_STRING | 2309
160160

161+
TLV_TYPE_DRIVER_ENTRY = TLV_META_TYPE_GROUP | 2320
162+
TLV_TYPE_DRIVER_BASENAME = TLV_META_TYPE_STRING | 2321
163+
TLV_TYPE_DRIVER_FILENAME = TLV_META_TYPE_STRING | 2322
164+
161165
TLV_TYPE_IMAGE_FILE = TLV_META_TYPE_STRING | 2400
162166
TLV_TYPE_IMAGE_FILE_PATH = TLV_META_TYPE_STRING | 2401
163167
TLV_TYPE_PROCEDURE_NAME = TLV_META_TYPE_STRING | 2402

metasploit-framework.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Gem::Specification.new do |spec|
6565
# are needed when there's no database
6666
spec.add_runtime_dependency 'metasploit-model'
6767
# Needed for Meterpreter
68-
spec.add_runtime_dependency 'metasploit-payloads', '1.1.16'
68+
spec.add_runtime_dependency 'metasploit-payloads', '1.1.19'
6969
# Needed for the next-generation POSIX Meterpreter
7070
spec.add_runtime_dependency 'metasploit_payloads-mettle', '0.0.6'
7171
# Needed by msfgui and other rpc components

modules/exploits/windows/local/capcom_sys_exec.rb

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,28 @@ def initialize(info={})
5151
end
5252

5353
def check
54-
if sysinfo['OS'] !~ /windows 7/i
54+
if sysinfo['OS'] !~ /windows (7|8)/i
5555
return Exploit::CheckCode::Unknown
5656
end
5757

58-
if sysinfo['Architecture'] =~ /(wow|x)64/i
59-
arch = ARCH_X86_64
60-
else
58+
if sysinfo['Architecture'] !~ /(wow|x)64/i
6159
return Exploit::CheckCode::Safe
6260
end
6361

64-
file_path = expand_path('%windir%') << '\\system32\\capcom.sys'
65-
return Exploit::CheckCode::Safe unless file_exist?(file_path)
62+
# Validate that the driver has been loaded and that
63+
# the version is the same as the one expected
64+
client.sys.config.getdrivers.each do |d|
65+
if d[:basename].downcase == 'capcom.sys'
66+
expected_checksum = '73c98438ac64a68e88b7b0afd11ba140'
67+
target_checksum = client.fs.file.md5(d[:filename])
68+
69+
if expected_checksum == Rex::Text.to_hex(target_checksum, '')
70+
return Exploit::CheckCode::Appears
71+
end
72+
end
73+
end
6674

67-
# TODO: check for the capcom.sys driver and its version.
68-
return Exploit::CheckCode::Appears
75+
return Exploit::CheckCode::Safe
6976
end
7077

7178
def exploit

0 commit comments

Comments
 (0)