diff --git a/core/ruby.rb b/core/ruby.rb index de1c81e27..f04f14978 100644 --- a/core/ruby.rb +++ b/core/ruby.rb @@ -28,6 +28,7 @@ require 'core/ruby/patches/webrick/cookie' require 'core/ruby/patches/webrick/genericserver' require 'core/ruby/patches/webrick/httpresponse' require 'core/ruby/patches/webrick/httpservlet/filehandler.rb' +require 'core/ruby/patches/webrick/httputils.rb' # @note Patching DataMapper Data Objects Adapter (dm-do-adapter) require 'core/ruby/patches/dm-do-adapter/adapter.rb' diff --git a/core/ruby/patches/webrick/httputils.rb b/core/ruby/patches/webrick/httputils.rb new file mode 100644 index 000000000..24348f945 --- /dev/null +++ b/core/ruby/patches/webrick/httputils.rb @@ -0,0 +1,33 @@ +# +# httputils.rb -- HTTPUtils Module +# +# Author: IPR -- Internet Programming with Ruby -- writers +# Copyright (c) 2000, 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou +# Copyright (c) 2002 Internet Programming with Ruby writers. All rights +# reserved. +# +# $IPR: httputils.rb,v 1.34 2003/06/05 21:34:08 gotoyuzo Exp $ + + +module WEBrick + + module HTTPUtils + + # Add support for additional mime types + def mime_type(filename, mime_tab) + suffix1 = (/\.(\w+)$/ =~ filename && $1.downcase) + suffix2 = (/\.(\w+)\.[\w\-]+$/ =~ filename && $1.downcase) + + # Add support for additional mime types + supported_mime_types = { + 'wav' => 'audio/x-wav' + } + + mime_tab.merge!(supported_mime_types) + + mime_tab[suffix1] || mime_tab[suffix2] || "application/octet-stream" + end + module_function :mime_type + + end +end diff --git a/extensions/demos/html/sound.wav b/extensions/demos/html/sound.wav new file mode 100644 index 000000000..e77a4fb06 Binary files /dev/null and b/extensions/demos/html/sound.wav differ diff --git a/modules/browser/play_sound/command.js b/modules/browser/play_sound/command.js new file mode 100644 index 000000000..40ca65995 --- /dev/null +++ b/modules/browser/play_sound/command.js @@ -0,0 +1,45 @@ +// +// Copyright 2011 Wade Alcorn wade@bindshell.net +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +beef.execute(function() { + + function playSound(url) { + function createSound(which) { + window.soundEmbed = document.createElement("audio"); + window.soundEmbed.setAttribute("src", which); + + window.soundEmbed.setAttribute("style", "display: none;"); + window.soundEmbed.setAttribute("autoplay", true); + + } + if (!window.soundEmbed) { + createSound(url); + } + else { + document.body.removeChild(window.soundEmbed); + window.soundEmbed.removed = true; + window.soundEmbed = null; + createSound(url); + } + window.soundEmbed.removed = false; + document.body.appendChild(window.soundEmbed); + } + + + + playSound("<%== @sound_file_uri %>"); + + beef.net.send("<%= @command_url %>", <%= @command_id %>, "Sound Played"); +}); diff --git a/modules/browser/play_sound/config.yaml b/modules/browser/play_sound/config.yaml new file mode 100644 index 000000000..d7a3d362c --- /dev/null +++ b/modules/browser/play_sound/config.yaml @@ -0,0 +1,25 @@ +# +# Copyright 2011 Wade Alcorn wade@bindshell.net +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +beef: + module: + Play_sound: + enable: true + category: "Browser" + name: "Play Sound" + description: "Play a sound on the hooked browser." + authors: ["Saafan"] + target: + working: ["All"] diff --git a/modules/browser/play_sound/module.rb b/modules/browser/play_sound/module.rb new file mode 100644 index 000000000..a9cce080f --- /dev/null +++ b/modules/browser/play_sound/module.rb @@ -0,0 +1,40 @@ +# +# Copyright 2011 Wade Alcorn wade@bindshell.net +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +class Play_sound < BeEF::Core::Command + + # set and return all options for this module + def self.options + configuration = BeEF::Core::Configuration.instance + + sound_file_url = "http://#{configuration.get("beef.http.host")}:#{configuration.get("beef.http.port")}/demos/sound.wav" + + return [{ + 'name' => 'sound_file_uri', + 'description' => 'The web accessable uri for the wave sound file', + 'ui_label' => 'Sound File Path', + 'value' => sound_file_url, + 'width' => '300px' + }] + end + + def post_execute + content = {} + content['result'] = @datastore['result'] + + save content + end + +end