diff --git a/data/sounds/default/session_open.mp3 b/data/sounds/default/session_open.mp3 new file mode 100755 index 0000000000..e39d303134 Binary files /dev/null and b/data/sounds/default/session_open.mp3 differ diff --git a/lib/msf/ui/console/command_dispatcher/exploit.rb b/lib/msf/ui/console/command_dispatcher/exploit.rb index 4d3fba0d8f..d3b9747484 100644 --- a/lib/msf/ui/console/command_dispatcher/exploit.rb +++ b/lib/msf/ui/console/command_dispatcher/exploit.rb @@ -155,7 +155,14 @@ class Exploit # If we didn't run a payload handler for this exploit it doesn't # make sense to complain to the user that we didn't get a session unless (mod.datastore["DisablePayloadHandler"]) - print_status("Exploit completed, but no session was created.") + fail_msg = 'Exploit completed, but no session was created.' + print_status(fail_msg) + begin + framework.events.on_session_fail(fail_msg) + rescue ::Exception => e + wlog("Exception in on_session_open event handler: #{e.class}: #{e}") + wlog("Call Stack\n#{e.backtrace.join("\n")}") + end end end end diff --git a/lib/msf/ui/console/framework_event_manager.rb b/lib/msf/ui/console/framework_event_manager.rb index a073a83b1d..b7f4bee872 100644 --- a/lib/msf/ui/console/framework_event_manager.rb +++ b/lib/msf/ui/console/framework_event_manager.rb @@ -37,6 +37,9 @@ module FrameworkEventManager end end + def on_session_fail(reason='') + end + # # Called when a session is closed and removed from the framework. # diff --git a/plugins/sounds.rb b/plugins/sounds.rb index 1db8e3bef5..7cd7dd84d8 100644 --- a/plugins/sounds.rb +++ b/plugins/sounds.rb @@ -14,11 +14,8 @@ module Msf class Plugin::EventSounds < Msf::Plugin - SESSION_CLOSE = 'try_harder' - SESSION_OPEN = 'excellent' - - attr_accessor :theme, :base, :queue, :queue_thread + attr_reader :try_harder, :session_open, :excellent include Msf::SessionEvent @@ -27,11 +24,16 @@ class Plugin::EventSounds < Msf::Plugin end def on_session_open(session) - play_sound(SESSION_OPEN) + sound = [excellent, session_open].sample + play_sound(sound) end def on_session_close(session, reason='') - play_sound(SESSION_CLOSE) + play_sound(session_close) + end + + def on_session_fail(reason='') + play_sound(try_harder) end def on_plugin_load @@ -67,9 +69,18 @@ class Plugin::EventSounds < Msf::Plugin end + def init_sound_paths + @try_harder = 'try_harder' + @session_open = 'session_open' + @excellent = 'excellent' + 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")