diff --git a/lib/msf/base/simple/exploit.rb b/lib/msf/base/simple/exploit.rb index afc2ec23d7..5fc96a5499 100644 --- a/lib/msf/base/simple/exploit.rb +++ b/lib/msf/base/simple/exploit.rb @@ -237,6 +237,9 @@ module Exploit # Report the failure (and attempt) in the database self.report_failure + + # Interrupt any session waiters in the handler + self.interrupt_handler end # # Calls the class method. diff --git a/lib/msf/core/exploit.rb b/lib/msf/core/exploit.rb index 41d6bea30d..bf4c8ec2e2 100644 --- a/lib/msf/core/exploit.rb +++ b/lib/msf/core/exploit.rb @@ -1193,9 +1193,19 @@ class Exploit < Msf::Module # value can be one of the Handler::constants. # def handler(*args) - return if not payload_instance - return if not handler_enabled? - return payload_instance.handler(*args) + return unless payload_instance + return unless handler_enabled? + payload_instance.handler(*args) + end + + # + # Break out of the session wait loop (WfsDelay) + # + def interrupt_handler + return unless payload_instance + return unless handler_enabled? + return unless payload_instance.respond_to?(:interrupt_wait_for_session) + payload_instance.interrupt_wait_for_session() end ## diff --git a/lib/msf/core/handler.rb b/lib/msf/core/handler.rb index 010fa580b7..f6b12009ca 100644 --- a/lib/msf/core/handler.rb +++ b/lib/msf/core/handler.rb @@ -162,6 +162,14 @@ module Handler return session end + # + # Interrupts a wait_for_session call by notifying with a nil event + # + def interrupt_wait_for_session + return unless session_waiter_event + session_waiter_event.notify(nil) + end + # # Set by the exploit module to configure handler #