CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/msf/ui/console/framework_event_manager.rb
Views: 1904
1
# -*- coding: binary -*-
2
module Msf
3
module Ui
4
module Console
5
6
###
7
#
8
# Handles events of various types that are sent from the framework.
9
#
10
###
11
module FrameworkEventManager
12
13
include Msf::SessionEvent
14
15
#
16
# Subscribes to the framework as a subscriber of various events.
17
#
18
def register_event_handlers
19
framework.events.add_session_subscriber(self)
20
end
21
22
#
23
# Unsubscribes from the framework.
24
#
25
def deregister_event_handlers
26
framework.events.remove_session_subscriber(self)
27
end
28
29
#
30
# Called when a session is registered with the framework.
31
#
32
def on_session_open(session)
33
select(nil,nil,nil,0.125) # Give the session time enough to register itself properly.
34
output.print_status("#{session.desc} session #{session.name} opened (#{session.tunnel_to_s}) at #{Time.now}")
35
if (Msf::Logging.session_logging_enabled? == true)
36
Msf::Logging.start_session_log(session)
37
end
38
end
39
40
def on_session_fail(reason='')
41
end
42
43
#
44
# Called when a session is closed and removed from the framework.
45
#
46
def on_session_close(session, reason='')
47
if (session.interacting == true)
48
output.print_line
49
end
50
51
# If logging had been enabled for this session, stop it now.
52
Msf::Logging::stop_session_log(session)
53
54
msg = "#{session.session_host} - #{session.desc} session #{session.name} closed."
55
if reason and reason.length > 0
56
msg << " Reason: #{reason}"
57
end
58
output.print_status(msg)
59
end
60
61
end
62
63
end
64
end
65
end
66
67
68