Class: Msf::Plugin::EventSounds
- Inherits:
-
Msf::Plugin
- Object
- Msf::Plugin
- Msf::Plugin::EventSounds
- Includes:
- SessionEvent
- Defined in:
- plugins/sounds.rb
Overview
This class hooks all session creation events and plays a sound
Instance Attribute Summary collapse
-
#base ⇒ Object
Returns the value of attribute base.
-
#excellent ⇒ Object
readonly
Returns the value of attribute excellent.
-
#exploit_worked ⇒ Object
readonly
Returns the value of attribute exploit_worked.
-
#got_a_shell ⇒ Object
readonly
Returns the value of attribute got_a_shell.
-
#queue ⇒ Object
Returns the value of attribute queue.
-
#queue_thread ⇒ Object
Returns the value of attribute queue_thread.
-
#theme ⇒ Object
Returns the value of attribute theme.
-
#try_harder ⇒ Object
readonly
Returns the value of attribute try_harder.
-
#wonderful ⇒ Object
readonly
Returns the value of attribute wonderful.
Attributes inherited from Msf::Plugin
Attributes included from Framework::Offspring
Instance Method Summary collapse
- #cleanup ⇒ Object
- #desc ⇒ Object
- #init_sound_paths ⇒ Object
-
#initialize(framework, opts) ⇒ EventSounds
constructor
A new instance of EventSounds.
- #name ⇒ Object
- #on_plugin_load ⇒ Object
- #on_plugin_unload ⇒ Object
- #on_session_close(session, reason = '') ⇒ Object
- #on_session_fail(_reason = '') ⇒ Object
- #on_session_open(_session) ⇒ Object
- #play_sound(event) ⇒ Object
- #start_sound_queue ⇒ Object
- #stop_sound_queue ⇒ Object
Methods included from SessionEvent
#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) ⇒ EventSounds
Returns a new instance of EventSounds.
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'plugins/sounds.rb', line 73 def initialize(framework, opts) super init_sound_paths self.queue = [] self.theme = opts['theme'] || 'default' self.base = File.join(Msf::Config.data_directory, 'sounds') self.framework.events.add_session_subscriber(self) start_sound_queue on_plugin_load end |
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base.
10 11 12 |
# File 'plugins/sounds.rb', line 10 def base @base end |
#excellent ⇒ Object (readonly)
Returns the value of attribute excellent.
11 12 13 |
# File 'plugins/sounds.rb', line 11 def excellent @excellent end |
#exploit_worked ⇒ Object (readonly)
Returns the value of attribute exploit_worked.
11 12 13 |
# File 'plugins/sounds.rb', line 11 def exploit_worked @exploit_worked end |
#got_a_shell ⇒ Object (readonly)
Returns the value of attribute got_a_shell.
11 12 13 |
# File 'plugins/sounds.rb', line 11 def got_a_shell @got_a_shell end |
#queue ⇒ Object
Returns the value of attribute queue.
10 11 12 |
# File 'plugins/sounds.rb', line 10 def queue @queue end |
#queue_thread ⇒ Object
Returns the value of attribute queue_thread.
10 11 12 |
# File 'plugins/sounds.rb', line 10 def queue_thread @queue_thread end |
#theme ⇒ Object
Returns the value of attribute theme.
10 11 12 |
# File 'plugins/sounds.rb', line 10 def theme @theme end |
#try_harder ⇒ Object (readonly)
Returns the value of attribute try_harder.
11 12 13 |
# File 'plugins/sounds.rb', line 11 def try_harder @try_harder end |
#wonderful ⇒ Object (readonly)
Returns the value of attribute wonderful.
11 12 13 |
# File 'plugins/sounds.rb', line 11 def wonderful @wonderful end |
Instance Method Details
#cleanup ⇒ Object
87 88 89 90 91 |
# File 'plugins/sounds.rb', line 87 def cleanup on_plugin_unload framework.events.remove_session_subscriber(self) stop_sound_queue end |
#desc ⇒ Object
97 98 99 |
# File 'plugins/sounds.rb', line 97 def desc 'Automatically plays a sound when various framework events occur' end |
#init_sound_paths ⇒ Object
65 66 67 68 69 70 71 |
# File 'plugins/sounds.rb', line 65 def init_sound_paths @try_harder = 'try_harder' @excellent = 'excellent' @got_a_shell = 'got_a_shell' @exploit_worked = 'exploit_worked' @wonderful = 'wonderful' end |
#name ⇒ Object
93 94 95 |
# File 'plugins/sounds.rb', line 93 def name 'sounds' end |
#on_plugin_load ⇒ Object
37 |
# File 'plugins/sounds.rb', line 37 def on_plugin_load; end |
#on_plugin_unload ⇒ Object
39 |
# File 'plugins/sounds.rb', line 39 def on_plugin_unload; end |
#on_session_close(session, reason = '') ⇒ Object
29 30 31 |
# File 'plugins/sounds.rb', line 29 def on_session_close(session, reason = '') # Cannot find an audio clip of muts saying something suitable for this. end |
#on_session_fail(_reason = '') ⇒ Object
33 34 35 |
# File 'plugins/sounds.rb', line 33 def on_session_fail(_reason = '') play_sound(try_harder) end |
#on_session_open(_session) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'plugins/sounds.rb', line 19 def on_session_open(_session) sound = [ excellent, got_a_shell, exploit_worked, wonderful ].sample play_sound(sound) end |
#play_sound(event) ⇒ Object
15 16 17 |
# File 'plugins/sounds.rb', line 15 def play_sound(event) queue.push(event) end |
#start_sound_queue ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'plugins/sounds.rb', line 41 def start_sound_queue self.queue_thread = Thread.new do loop do while (event = queue.shift) path = ::File.join(base, theme, "#{event}.wav") if ::File.exist?(path) Rex::Compat.play_sound(path) else print_status("Warning: sound file not found: #{path}") end end select(nil, nil, nil, 0.25) end rescue ::Exception => e print_status("Sound plugin: fatal error #{e} #{e.backtrace}") end end |
#stop_sound_queue ⇒ Object
59 60 61 62 63 |
# File 'plugins/sounds.rb', line 59 def stop_sound_queue queue_thread.kill if queue_thread self.queue_thread = nil self.queue = [] end |