From 0c1d02c9404e88a3f9e990a3f452b95dd376b325 Mon Sep 17 00:00:00 2001 From: James Lee Date: Thu, 11 Dec 2014 20:03:11 -0600 Subject: [PATCH] Fix event handlers on ruby 2 Fixes #4219 --- lib/msf/core/event_dispatcher.rb | 8 ++++---- lib/msf/core/payload.rb | 1 - plugins/event_tester.rb | 14 ++++++++------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/msf/core/event_dispatcher.rb b/lib/msf/core/event_dispatcher.rb index a2f72d2872..0da7af8048 100644 --- a/lib/msf/core/event_dispatcher.rb +++ b/lib/msf/core/event_dispatcher.rb @@ -176,7 +176,7 @@ class EventDispatcher found = false case event when "on" - if respond_to?(subscribers) + if respond_to?(subscribers, true) found = true self.send(subscribers).each do |sub| next if not sub.respond_to?(name) @@ -221,11 +221,11 @@ protected array.delete(subscriber) end - attr_accessor :general_event_subscribers # :nodoc: attr_accessor :custom_event_subscribers # :nodoc: - attr_accessor :exploit_event_subscribers # :nodoc: - attr_accessor :session_event_subscribers # :nodoc: attr_accessor :db_event_subscribers # :nodoc: + attr_accessor :exploit_event_subscribers # :nodoc: + attr_accessor :general_event_subscribers # :nodoc: + attr_accessor :session_event_subscribers # :nodoc: attr_accessor :ui_event_subscribers # :nodoc: end diff --git a/lib/msf/core/payload.rb b/lib/msf/core/payload.rb index 34bdeac9ef..8cfbfc841f 100644 --- a/lib/msf/core/payload.rb +++ b/lib/msf/core/payload.rb @@ -449,7 +449,6 @@ class Payload < Msf::Module # def on_session(session) - # If this payload is associated with an exploit, inform the exploit # that a session has been created and potentially shut down any # open sockets. This allows active exploits to continue hammering diff --git a/plugins/event_tester.rb b/plugins/event_tester.rb index 3b7d2afc33..2320a2c40f 100644 --- a/plugins/event_tester.rb +++ b/plugins/event_tester.rb @@ -21,17 +21,19 @@ class Plugin::EventTester < Msf::Plugin def initialize(framework, opts) super @subscriber = Subscriber.new - framework.events.add_exploit_subscriber(@subscriber) - framework.events.add_session_subscriber(@subscriber) - framework.events.add_general_subscriber(@subscriber) + framework.events.add_custom_subscriber(@subscriber) framework.events.add_db_subscriber(@subscriber) + framework.events.add_exploit_subscriber(@subscriber) + framework.events.add_general_subscriber(@subscriber) + framework.events.add_session_subscriber(@subscriber) framework.events.add_ui_subscriber(@subscriber) end def cleanup - framework.events.remove_exploit_subscriber(@subscriber) - framework.events.remove_session_subscriber(@subscriber) - framework.events.remove_general_subscriber(@subscriber) + framework.events.remove_custom_subscriber(@subscriber) framework.events.remove_db_subscriber(@subscriber) + framework.events.remove_exploit_subscriber(@subscriber) + framework.events.remove_general_subscriber(@subscriber) + framework.events.remove_session_subscriber(@subscriber) framework.events.remove_ui_subscriber(@subscriber) end end