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:
a.m.saafan@gmail.com
2011-09-27 13:25:02 +00:00
parent 6658eff14c
commit c6de8c1a0d
6 changed files with 144 additions and 0 deletions

View File

@@ -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'

View 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

Binary file not shown.

View 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");
});

View 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"]

View 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