Class: Msf::Plugin::EventLibnotify
Instance Attribute Summary
Attributes inherited from Msf::Plugin
#opts
#framework
Instance Method Summary
collapse
#on_session_command, #on_session_download, #on_session_filedelete, #on_session_interact, #on_session_output, #on_session_upload
Methods inherited from Msf::Plugin
#add_console_dispatcher, create, #flush, #input, #output, #print, #print_error, #print_good, #print_line, #print_status, #print_warning, #remove_console_dispatcher
Constructor Details
#initialize(framework, opts) ⇒ EventLibnotify
Returns a new instance of EventLibnotify.
13
14
15
16
17
18
19
20
21
22
23
|
# File 'plugins/libnotify.rb', line 13
def initialize(framework, opts)
super
@bin = opts[:bin] || opts['bin'] || `which notify-send`.chomp
@bin_opts = opts[:opts] || opts['opts'] || '--app-name=Metasploit'
raise 'libnotify not found' if @bin.empty?
self.framework.events.add_session_subscriber(self)
self.framework.events.add_db_subscriber(self)
end
|
Instance Method Details
#cleanup ⇒ Object
79
80
81
82
|
# File 'plugins/libnotify.rb', line 79
def cleanup
framework.events.remove_session_subscriber(self)
framework.events.remove_db_subscriber(self)
end
|
#desc ⇒ Object
88
89
90
|
# File 'plugins/libnotify.rb', line 88
def desc
'Send desktop notification with libnotify on sessions and db events'
end
|
#name ⇒ Object
84
85
86
|
# File 'plugins/libnotify.rb', line 84
def name
'libnotify'
end
|
#notify_send(urgency, title, message) ⇒ Object
25
26
27
28
29
|
# File 'plugins/libnotify.rb', line 25
def notify_send(urgency, title, message)
system(@bin, @bin_opts, '-u', urgency, title, message)
rescue StandarError => e
puts "Error running #{@bin}: #{e.message}"
end
|
#on_db_client(client) ⇒ Object
75
76
77
|
# File 'plugins/libnotify.rb', line 75
def on_db_client(client)
notify_send('critical', 'New client', "New client connected: #{client.ua_string}")
end
|
#on_db_host(host) ⇒ Object
46
47
48
49
|
# File 'plugins/libnotify.rb', line 46
def on_db_host(host)
notify_send('normal', 'New host',
"Address: #{host.address}\nOS: #{host.os_name}")
end
|
#on_db_host_state(host, _ostate) ⇒ Object
51
52
53
54
|
# File 'plugins/libnotify.rb', line 51
def on_db_host_state(host, _ostate)
notify_send('normal', "Host #{host.address} changed",
"OS: #{host.os_name}\nNb Services: #{host.service_count}\nNb vulns: #{host.vuln_count}\n")
end
|
#on_db_ref(ref) ⇒ Object
71
72
73
|
# File 'plugins/libnotify.rb', line 71
def on_db_ref(ref)
notify_send('normal', 'New ref', "Reference #{ref.name} added in database.")
end
|
#on_db_service(service) ⇒ Object
56
57
58
59
|
# File 'plugins/libnotify.rb', line 56
def on_db_service(service)
notify_send('normal', 'New service',
"New service: #{service.host.address}:#{service.port}")
end
|
#on_db_service_state(service, _port, _ostate) ⇒ Object
61
62
63
64
|
# File 'plugins/libnotify.rb', line 61
def on_db_service_state(service, _port, _ostate)
notify_send('normal', "Service #{service.host.address}:#{service.port} changed",
"Name: #{service.name}\nState: #{service.state}\nProto: #{service.proto}\nInfo: #{service.info}")
end
|
#on_db_vuln(vuln) ⇒ Object
66
67
68
69
|
# File 'plugins/libnotify.rb', line 66
def on_db_vuln(vuln)
notify_send('critical', "New vulnerability on #{vuln.host.address}:#{vuln.service ? vuln.service.port : '0'}",
"Vuln: #{vuln.name}\nInfos: #{vuln.info}")
end
|
#on_session_close(session, reason = '') ⇒ Object
37
38
39
40
|
# File 'plugins/libnotify.rb', line 37
def on_session_close(session, reason = '')
notify_send('normal', 'Connection closed',
"Session:#{session.sid} Type:#{session.type} closed.\n#{reason}")
end
|
#on_session_fail(reason = '') ⇒ Object
42
43
44
|
# File 'plugins/libnotify.rb', line 42
def on_session_fail(reason = '')
notify_send('critical', 'Session Failure!', reason)
end
|
#on_session_open(session) ⇒ Object
31
32
33
34
35
|
# File 'plugins/libnotify.rb', line 31
def on_session_open(session)
notify_send('normal', 'Got Shell!',
"New Session: #{session.sid}\nIP: #{session.session_host}\nPeer: #{session.tunnel_peer}\n"\
"Platform: #{session.platform}\nType: #{session.type}")
end
|