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.
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'plugins/sounds.rb', line 85 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 self.on_plugin_load end |
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base
16 17 18 |
# File 'plugins/sounds.rb', line 16 def base @base end |
#excellent ⇒ Object (readonly)
Returns the value of attribute excellent
17 18 19 |
# File 'plugins/sounds.rb', line 17 def excellent @excellent end |
#exploit_worked ⇒ Object (readonly)
Returns the value of attribute exploit_worked
17 18 19 |
# File 'plugins/sounds.rb', line 17 def exploit_worked @exploit_worked end |
#got_a_shell ⇒ Object (readonly)
Returns the value of attribute got_a_shell
17 18 19 |
# File 'plugins/sounds.rb', line 17 def got_a_shell @got_a_shell end |
#queue ⇒ Object
Returns the value of attribute queue
16 17 18 |
# File 'plugins/sounds.rb', line 16 def queue @queue end |
#queue_thread ⇒ Object
Returns the value of attribute queue_thread
16 17 18 |
# File 'plugins/sounds.rb', line 16 def queue_thread @queue_thread end |
#theme ⇒ Object
Returns the value of attribute theme
16 17 18 |
# File 'plugins/sounds.rb', line 16 def theme @theme end |
#try_harder ⇒ Object (readonly)
Returns the value of attribute try_harder
17 18 19 |
# File 'plugins/sounds.rb', line 17 def try_harder @try_harder end |
#wonderful ⇒ Object (readonly)
Returns the value of attribute wonderful
17 18 19 |
# File 'plugins/sounds.rb', line 17 def wonderful @wonderful end |
Instance Method Details
#cleanup ⇒ Object
99 100 101 102 103 |
# File 'plugins/sounds.rb', line 99 def cleanup self.on_plugin_unload self.framework.events.remove_session_subscriber(self) stop_sound_queue end |
#desc ⇒ Object
109 110 111 |
# File 'plugins/sounds.rb', line 109 def desc "Automatically plays a sound when various framework events occur" end |
#init_sound_paths ⇒ Object
76 77 78 79 80 81 82 |
# File 'plugins/sounds.rb', line 76 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
105 106 107 |
# File 'plugins/sounds.rb', line 105 def name "sounds" end |
#on_plugin_load ⇒ Object
43 44 |
# File 'plugins/sounds.rb', line 43 def on_plugin_load end |
#on_plugin_unload ⇒ Object
46 47 |
# File 'plugins/sounds.rb', line 46 def on_plugin_unload end |
#on_session_close(session, reason = '') ⇒ Object
35 36 37 |
# File 'plugins/sounds.rb', line 35 def on_session_close(session, reason='') # Cannot find an audio clip of muts saying something suitable for this. end |
#on_session_fail(reason = '') ⇒ Object
39 40 41 |
# File 'plugins/sounds.rb', line 39 def on_session_fail(reason='') play_sound(try_harder) end |
#on_session_open(session) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'plugins/sounds.rb', line 25 def on_session_open(session) sound = [ excellent, got_a_shell, exploit_worked, wonderful ].sample play_sound(sound) end |
#play_sound(event) ⇒ Object
21 22 23 |
# File 'plugins/sounds.rb', line 21 def play_sound(event) self.queue.push(event) end |
#start_sound_queue ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'plugins/sounds.rb', line 49 def start_sound_queue self.queue_thread = Thread.new do begin while(true) while(event = self.queue.shift) path = ::File.join(self.base, self.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 end |
#stop_sound_queue ⇒ Object
69 70 71 72 73 |
# File 'plugins/sounds.rb', line 69 def stop_sound_queue self.queue_thread.kill if self.queue_thread self.queue_thread = nil self.queue = [] end |