From 6c16a89328f96e23fa248043dfa242d0fc31ae58 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 7 Jan 2013 01:30:44 -0500 Subject: [PATCH] Added simple adblock checks for IE from issue #803 --- .../browser/detect_simple_adblock/command.js | 40 +++++++++++++++++++ .../browser/detect_simple_adblock/config.yaml | 16 ++++++++ .../browser/detect_simple_adblock/module.rb | 14 +++++++ 3 files changed, 70 insertions(+) create mode 100644 modules/browser/detect_simple_adblock/command.js create mode 100644 modules/browser/detect_simple_adblock/config.yaml create mode 100644 modules/browser/detect_simple_adblock/module.rb diff --git a/modules/browser/detect_simple_adblock/command.js b/modules/browser/detect_simple_adblock/command.js new file mode 100644 index 000000000..afcc4a672 --- /dev/null +++ b/modules/browser/detect_simple_adblock/command.js @@ -0,0 +1,40 @@ +// Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net +// Browser Exploitation Framework (BeEF) - http://beefproject.com +// See the file 'doc/COPYING' for copying permission +// + +beef.execute(function() { + + if (document.getElementById('adblock_img')) { + return "Img already created"; + } + + var img = new Image(); + img.setAttribute("style","visibility:hidden"); + img.setAttribute("width","0"); + img.setAttribute("height","0"); + img.src = 'http://simple-adblock.com/adblocktest/files/adbanner.gif'; + img.id = 'adblock_img'; + img.setAttribute("attr","start"); + img.onerror = function() { + this.setAttribute("attr","error"); + }; + img.onload = function() { + this.setAttribute("attr","load"); + }; + + document.body.appendChild(img); + + setTimeout(function() { + var img = document.getElementById('adblock_img'); + if (img.getAttribute("attr") == "error") { + beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Adblock returned an error'); + } else if (img.getAttribute("attr") == "load") { + beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Adblock is disabled or not installed'); + } else if (img.getAttribute("attr") == "start") { + beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Adblock is enabled'); + }; + document.body.removeChild(img); + }, 10000); + +}); diff --git a/modules/browser/detect_simple_adblock/config.yaml b/modules/browser/detect_simple_adblock/config.yaml new file mode 100644 index 000000000..b0ac675ba --- /dev/null +++ b/modules/browser/detect_simple_adblock/config.yaml @@ -0,0 +1,16 @@ +# +# Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - http://beefproject.com +# See the file 'doc/COPYING' for copying permission +# +beef: + module: + detect_simple_adblock: + enable: true + category: "Browser" + name: "Detect Simple Adblock" + description: "This module checks if the Simple Adblock module is active." + authors: ["sussurro"] + target: + working: ["IE"] + not_working: ["All"] diff --git a/modules/browser/detect_simple_adblock/module.rb b/modules/browser/detect_simple_adblock/module.rb new file mode 100644 index 000000000..83b626b3e --- /dev/null +++ b/modules/browser/detect_simple_adblock/module.rb @@ -0,0 +1,14 @@ +# +# Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net +# Browser Exploitation Framework (BeEF) - http://beefproject.com +# See the file 'doc/COPYING' for copying permission +# +class Detect_simple_adblock< BeEF::Core::Command + + def post_execute + content = {} + content['simple_adblock'] = @datastore['simple_adblock'] if not @datastore['simple_adblock'].nil? + save content + end + +end