1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-10-29 18:07:27 +01:00

Replace error handling methods

This commit is contained in:
Josh 2016-01-06 18:53:54 -06:00
parent 0de69a9d40
commit 60c506d7fb

View File

@ -111,9 +111,9 @@ class Metasploit3 < Msf::Post
client.core.migrate(target_pid) client.core.migrate(target_pid)
print_good("Successfully migrated to #{client.sys.process.open.name} (#{client.sys.process.open.pid}) as: #{client.sys.config.getuid}") print_good("Successfully migrated to #{client.sys.process.open.name} (#{client.sys.process.open.pid}) as: #{client.sys.config.getuid}")
return true return true
rescue ::Exception => e rescue ::Rex::Post::Meterpreter::RequestError => error
print_error("Could not migrate to #{proc_name}.") print_error("Could not migrate to #{proc_name}.")
print_error(e.to_s) print_error(error.to_s)
return false return false
end end
end end
@ -125,9 +125,9 @@ class Metasploit3 < Msf::Post
proc = session.sys.process.execute(proc_name, nil, {'Hidden' => true }) proc = session.sys.process.execute(proc_name, nil, {'Hidden' => true })
print_good("Successfully spawned #{proc_name}") print_good("Successfully spawned #{proc_name}")
return proc.pid return proc.pid
rescue ::Exception => e rescue ::Rex::Post::Meterpreter::RequestError => error
print_error("Could not spawn #{proc_name}.") print_error("Could not spawn #{proc_name}.")
print_error(e.to_s) print_error(error.to_s)
return nil return nil
end end
end end
@ -138,9 +138,9 @@ class Metasploit3 < Msf::Post
print_status("Trying to kill original process #{proc_name} (#{proc_pid})") print_status("Trying to kill original process #{proc_name} (#{proc_pid})")
session.sys.process.kill(proc_pid) session.sys.process.kill(proc_pid)
print_good("Successfully killed process #{proc_name} (#{proc_pid})") print_good("Successfully killed process #{proc_name} (#{proc_pid})")
rescue ::Exception => e rescue ::Rex::Post::Meterpreter::RequestError => error
print_error("Could not kill original process #{proc_name} (#{proc_pid})") print_error("Could not kill original process #{proc_name} (#{proc_pid})")
print_error(e.to_s) print_error(error.to_s)
end end
end end
end end