From 82865f6ffab5ca9b8225eac5b6608343ad58f2d2 Mon Sep 17 00:00:00 2001 From: Wade Date: Mon, 21 Nov 2011 17:15:39 +1000 Subject: [PATCH] popup blocker detection added --- core/main/client/browser/cookie.js | 30 +++++++------- core/main/client/browser/popup.js | 39 +++++++++++++++++++ core/main/handlers/modules/beefjs.rb | 2 +- .../browser/detect_popup_blocker/command.js | 20 ++++++++++ .../browser/detect_popup_blocker/config.yaml | 25 ++++++++++++ .../browser/detect_popup_blocker/module.rb | 24 ++++++++++++ modules/browser/detect_visited_urls/module.rb | 7 +++- 7 files changed, 130 insertions(+), 17 deletions(-) create mode 100644 core/main/client/browser/popup.js create mode 100644 modules/browser/detect_popup_blocker/command.js create mode 100644 modules/browser/detect_popup_blocker/config.yaml create mode 100644 modules/browser/detect_popup_blocker/module.rb diff --git a/core/main/client/browser/cookie.js b/core/main/client/browser/cookie.js index a56d9de6e..880ef215b 100644 --- a/core/main/client/browser/cookie.js +++ b/core/main/client/browser/cookie.js @@ -1,18 +1,18 @@ -// -// 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. -// +// +// 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. +// /*! * @literal object: beef.browser.cookie * diff --git a/core/main/client/browser/popup.js b/core/main/client/browser/popup.js new file mode 100644 index 000000000..36c991842 --- /dev/null +++ b/core/main/client/browser/popup.js @@ -0,0 +1,39 @@ +// +// 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. +// +/*! + * @literal object: beef.browser.popup + * + * Provides fuctions for working with cookies. + * Several functions adopted from http://davidwalsh.name/popup-block-javascript + * Original author unknown. + * + */ +beef.browser.popup = { + + blocker_enbabled: function () + { + screenParams = beef.browser.getScreenParams(); + var popUp = window.open('/', 'windowName0', 'width=1, height=1, left='+screenParams.width+', top='+screenParams.height+', scrollbars, resizable'); + if (popUp == null || typeof(popUp)=='undefined') { + return true; + } else { + popUp.close(); + return false; + } + } +}; + +beef.regCmp('beef.browser.popup'); \ No newline at end of file diff --git a/core/main/handlers/modules/beefjs.rb b/core/main/handlers/modules/beefjs.rb index fd35c8c48..8da9385b2 100644 --- a/core/main/handlers/modules/beefjs.rb +++ b/core/main/handlers/modules/beefjs.rb @@ -29,7 +29,7 @@ module Modules beefjs = '' # @note location of sub files beefjs_path = "#{$root_dir}/core/main/client/" - js_sub_files = %w(lib/jquery-1.5.2.min.js lib/evercookie.js lib/json2.js beef.js browser.js browser/cookie.js session.js os.js dom.js logger.js net.js updater.js encode/base64.js encode/json.js net/local.js init.js mitb.js) + js_sub_files = %w(lib/jquery-1.5.2.min.js lib/evercookie.js lib/json2.js beef.js browser.js browser/cookie.js browser/popup.js session.js os.js dom.js logger.js net.js updater.js encode/base64.js encode/json.js net/local.js init.js mitb.js) # @note construct the beefjs string from file(s) js_sub_files.each {|js_sub_file_name| diff --git a/modules/browser/detect_popup_blocker/command.js b/modules/browser/detect_popup_blocker/command.js new file mode 100644 index 000000000..8141e101f --- /dev/null +++ b/modules/browser/detect_popup_blocker/command.js @@ -0,0 +1,20 @@ +// +// 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() { + + beef.net.send("<%= @command_url %>", <%= @command_id %>, "popup_blocker_enabled="+beef.browser.popup.blocker_enbabled()); + +}); diff --git a/modules/browser/detect_popup_blocker/config.yaml b/modules/browser/detect_popup_blocker/config.yaml new file mode 100644 index 000000000..00b3e31bd --- /dev/null +++ b/modules/browser/detect_popup_blocker/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: + detect_popup_blocker: + enable: true + category: "Browser" + name: "Detect Popup Blocker" + description: "Detect if popup blocker is enabled." + authors: ["wade"] + target: + user_notify: ["All"] diff --git a/modules/browser/detect_popup_blocker/module.rb b/modules/browser/detect_popup_blocker/module.rb new file mode 100644 index 000000000..d7a09a6b0 --- /dev/null +++ b/modules/browser/detect_popup_blocker/module.rb @@ -0,0 +1,24 @@ +# +# 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 Detect_popup_blocker < BeEF::Core::Command + + def post_execute + content = {} + content['popup_blocker_enabled'] = @datastore['popup_blocker_enabled'] + save content + end + +end diff --git a/modules/browser/detect_visited_urls/module.rb b/modules/browser/detect_visited_urls/module.rb index facdaeea5..580853692 100644 --- a/modules/browser/detect_visited_urls/module.rb +++ b/modules/browser/detect_visited_urls/module.rb @@ -17,7 +17,12 @@ class Detect_visited_urls < BeEF::Core::Command def self.options return [ - { 'ui_label'=>'URL(s)', 'name'=>'urls', 'description' => 'Enter target URL(s)', 'type'=>'textarea', 'value'=>'http://beefproject.com/', 'width'=>'200px' } + { 'ui_label'=>'URL(s)', + 'name'=>'urls', + 'description' => 'Enter target URL(s)', + 'type'=>'textarea', + 'value'=>'http://beefproject.com/', + 'width'=>'200px' } ] end