restore original module RHOST on abort

GSoC/Meterpreter_Web_Console
Brent Cook 2017-11-28 12:04:19 -06:00
parent 3f9b124752
commit db6377134e
1 changed files with 5 additions and 1 deletions

View File

@ -48,12 +48,15 @@ class Exploit
end end
def exploit_single(opts, rhost = nil) def exploit_single(opts, rhost = nil)
orig_rhost = mod.datastore['RHOST']
begin begin
mod.datastore['RHOST'] = rhost if rhost mod.datastore['RHOST'] = rhost if orig_rhost
session = mod.exploit_simple(opts) session = mod.exploit_simple(opts)
rescue ::Interrupt rescue ::Interrupt
mod.datastore['RHOST'] = orig_rhost
raise $! raise $!
rescue ::Exception => e rescue ::Exception => e
mod.datastore['RHOST'] = orig_rhost
print_error("Exploit exception (#{mod.refname}): #{e.class} #{e}") print_error("Exploit exception (#{mod.refname}): #{e.class} #{e}")
if e.class.to_s != 'Msf::OptionValidateError' if e.class.to_s != 'Msf::OptionValidateError'
print_error("Call stack:") print_error("Call stack:")
@ -97,6 +100,7 @@ class Exploit
end end
end end
end end
mod.datastore['RHOST'] = orig_rhost
end end
def cmd_exploit_tabs(str, words) def cmd_exploit_tabs(str, words)