diff --git a/lib/msf/ui/console/command_dispatcher/exploit.rb b/lib/msf/ui/console/command_dispatcher/exploit.rb index 749a12ec56..8264119f1e 100644 --- a/lib/msf/ui/console/command_dispatcher/exploit.rb +++ b/lib/msf/ui/console/command_dispatcher/exploit.rb @@ -48,12 +48,15 @@ class Exploit end def exploit_single(opts, rhost = nil) + orig_rhost = mod.datastore['RHOST'] begin - mod.datastore['RHOST'] = rhost if rhost + mod.datastore['RHOST'] = rhost if orig_rhost session = mod.exploit_simple(opts) rescue ::Interrupt + mod.datastore['RHOST'] = orig_rhost raise $! rescue ::Exception => e + mod.datastore['RHOST'] = orig_rhost print_error("Exploit exception (#{mod.refname}): #{e.class} #{e}") if e.class.to_s != 'Msf::OptionValidateError' print_error("Call stack:") @@ -97,6 +100,7 @@ class Exploit end end end + mod.datastore['RHOST'] = orig_rhost end def cmd_exploit_tabs(str, words)