forked from rapid7/metasploit-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sounds.rb
115 lines (90 loc) · 2.19 KB
/
sounds.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#
# $Id$
# $Revision$
#
module Msf
###
#
# This class hooks all session creation events and plays a sound
#
###
class Plugin::EventSounds < Msf::Plugin
attr_accessor :theme, :base, :queue, :queue_thread
attr_reader :try_harder, :excellent, :got_a_shell, :exploit_worked, :wonderful
include Msf::SessionEvent
def play_sound(event)
self.queue.push(event)
end
def on_session_open(session)
sound = [
excellent,
got_a_shell,
exploit_worked,
wonderful
].sample
play_sound(sound)
end
def on_session_close(session, reason='')
# Cannot find an audio clip of muts saying something suitable for this.
end
def on_session_fail(reason='')
play_sound(try_harder)
end
def on_plugin_load
end
def on_plugin_unload
end
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
def stop_sound_queue
self.queue_thread.kill if self.queue_thread
self.queue_thread = nil
self.queue = []
end
def init_sound_paths
@try_harder = 'try_harder'
@excellent = 'excellent'
@got_a_shell = 'got_a_shell'
@exploit_worked = 'exploit_worked'
@wonderful = 'wonderful'
end
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
def cleanup
self.on_plugin_unload
self.framework.events.remove_session_subscriber(self)
stop_sound_queue
end
def name
"sounds"
end
def desc
"Automatically plays a sound when various framework events occur"
end
end
end