2005-07-16 08:12:58 +00:00
|
|
|
module Msf
|
|
|
|
module Ui
|
|
|
|
module Console
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# Handles events of various types that are sent from the framework.
|
|
|
|
#
|
|
|
|
###
|
|
|
|
module FrameworkEventManager
|
|
|
|
|
2005-10-30 22:20:29 +00:00
|
|
|
include Msf::SessionEvent
|
2005-07-16 08:12:58 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Subscribes to the framework as a subscriber of various events.
|
|
|
|
#
|
|
|
|
def register_event_handlers
|
|
|
|
framework.events.add_session_subscriber(self)
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Unsubscribes from the framework.
|
|
|
|
#
|
|
|
|
def deregister_event_handlers
|
|
|
|
framework.events.remove_session_subscriber(self)
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Called when a session is registered with the framework.
|
|
|
|
#
|
|
|
|
def on_session_open(session)
|
2010-10-18 21:08:48 +00:00
|
|
|
select(nil,nil,nil,0.125) # Give the session time enough to register itself properly.
|
2010-05-03 20:06:25 +00:00
|
|
|
output.print_status("#{session.desc} session #{session.name} opened (#{session.tunnel_to_s}) at #{Time.now}")
|
2005-10-02 03:21:26 +00:00
|
|
|
if (Msf::Logging.session_logging_enabled? == true)
|
|
|
|
Msf::Logging.start_session_log(session)
|
|
|
|
end
|
2005-07-16 08:12:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Called when a session is closed and removed from the framework.
|
|
|
|
#
|
2010-02-23 05:59:30 +00:00
|
|
|
def on_session_close(session, reason='')
|
2005-07-17 06:01:11 +00:00
|
|
|
if (session.interacting == true)
|
|
|
|
output.print_line
|
|
|
|
end
|
|
|
|
|
2005-10-02 03:21:26 +00:00
|
|
|
# If logging had been enabled for this session, stop it now.
|
|
|
|
Msf::Logging::stop_session_log(session)
|
|
|
|
|
2010-02-23 05:59:30 +00:00
|
|
|
msg = "#{session.desc} session #{session.name} closed."
|
2010-03-10 06:43:46 +00:00
|
|
|
if reason and reason.length > 0
|
2010-02-23 05:59:30 +00:00
|
|
|
msg << " Reason: #{reason}"
|
|
|
|
end
|
|
|
|
output.print_status(msg)
|
2005-07-16 08:12:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
2010-01-04 21:54:32 +00:00
|
|
|
end
|
2010-03-08 05:31:21 +00:00
|
|
|
|