Added Play Sound module. Also, added support for WEBrick custom MIME types. Fixes issue 51 .
git-svn-id: https://beef.googlecode.com/svn/trunk@1312 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
This commit is contained in:
@@ -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'
|
||||
|
||||
33
core/ruby/patches/webrick/httputils.rb
Normal file
33
core/ruby/patches/webrick/httputils.rb
Normal file
@@ -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
|
||||
BIN
extensions/demos/html/sound.wav
Normal file
BIN
extensions/demos/html/sound.wav
Normal file
Binary file not shown.
45
modules/browser/play_sound/command.js
Normal file
45
modules/browser/play_sound/command.js
Normal file
@@ -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");
|
||||
});
|
||||
25
modules/browser/play_sound/config.yaml
Normal file
25
modules/browser/play_sound/config.yaml
Normal file
@@ -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"]
|
||||
40
modules/browser/play_sound/module.rb
Normal file
40
modules/browser/play_sound/module.rb
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user