//1// Copyright (c) 2006-2025 Wade Alcorn - [email protected]2// Browser Exploitation Framework (BeEF) - https://beefproject.com3// See the file 'doc/COPYING' for copying permission4//56/*!7* BeEF JS Library <%= @beef_version %>8* Register the BeEF JS on the window object.9*/1011$j = jQuery.noConflict();1213if(typeof beef === 'undefined' && typeof window.beef === 'undefined') {1415/**16* Register the BeEF JS on the window object.17* @namespace {Object} BeefJS18* @property {string} version BeEf Version19* @property {boolean} pageIsLoaded This gets set to true during window.onload(). It's a useful hack when messing with document.write().20* @property {array} onpopstate An array containing functions to be executed by the window.onpopstate() method.21* @property {array} onclose An array containing functions to be executed by the window.onclose() method.22* @property {array} commands An array containing functions to be executed by Beef.23* @property {array} components An array containing all the BeEF JS components.24*/2526var BeefJS = {2728version: '<%= @beef_version %>',29pageIsLoaded: false,30onpopstate: new Array(),31onclose: new Array(),32commands: new Array(),33components: new Array(),3435/**36* Adds a function to display debug messages (wraps console.log())37* @param: {string} the debug string to return38*/39debug: function(msg) {40isDebug = '<%= @client_debug %>'41if (typeof console == "object" && typeof console.log == "function" && isDebug === 'true') {42var currentdate = new Date();43var pad = function(n){return ("0" + n).slice(-2);}44var datetime = currentdate.getFullYear() + "-"45+ pad(currentdate.getMonth()+1) + "-"46+ pad(currentdate.getDate()) + " "47+ pad(currentdate.getHours()) + ":"48+ pad(currentdate.getMinutes()) + ":"49+ pad(currentdate.getSeconds());50console.log('['+datetime+'] '+msg);51} else {52// TODO: maybe add a callback to BeEF server for debugging purposes53//window.alert(msg);54}55},5657/**58* Adds a function to execute.59* @param: {Function} the function to execute.60*/61execute: function(fn) {62if ( typeof beef.websocket == "undefined"){63this.commands.push(fn);64}else{65fn();66}67},6869/**70* Registers a component in BeEF JS.71* @params: {String} the component.72*73* Components are very important to register so the framework does not74* send them back over and over again.75*/76regCmp: function(component) {77this.components.push(component);78}7980};8182window.beef = BeefJS;83}848586