Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/core/main/client/beef.js
1154 views
1
//
2
// Copyright (c) 2006-2025 Wade Alcorn - [email protected]
3
// Browser Exploitation Framework (BeEF) - https://beefproject.com
4
// See the file 'doc/COPYING' for copying permission
5
//
6
7
/*!
8
* BeEF JS Library <%= @beef_version %>
9
* Register the BeEF JS on the window object.
10
*/
11
12
$j = jQuery.noConflict();
13
14
if(typeof beef === 'undefined' && typeof window.beef === 'undefined') {
15
16
/**
17
* Register the BeEF JS on the window object.
18
* @namespace {Object} BeefJS
19
* @property {string} version BeEf Version
20
* @property {boolean} pageIsLoaded This gets set to true during window.onload(). It's a useful hack when messing with document.write().
21
* @property {array} onpopstate An array containing functions to be executed by the window.onpopstate() method.
22
* @property {array} onclose An array containing functions to be executed by the window.onclose() method.
23
* @property {array} commands An array containing functions to be executed by Beef.
24
* @property {array} components An array containing all the BeEF JS components.
25
*/
26
27
var BeefJS = {
28
29
version: '<%= @beef_version %>',
30
pageIsLoaded: false,
31
onpopstate: new Array(),
32
onclose: new Array(),
33
commands: new Array(),
34
components: new Array(),
35
36
/**
37
* Adds a function to display debug messages (wraps console.log())
38
* @param: {string} the debug string to return
39
*/
40
debug: function(msg) {
41
isDebug = '<%= @client_debug %>'
42
if (typeof console == "object" && typeof console.log == "function" && isDebug === 'true') {
43
var currentdate = new Date();
44
var pad = function(n){return ("0" + n).slice(-2);}
45
var datetime = currentdate.getFullYear() + "-"
46
+ pad(currentdate.getMonth()+1) + "-"
47
+ pad(currentdate.getDate()) + " "
48
+ pad(currentdate.getHours()) + ":"
49
+ pad(currentdate.getMinutes()) + ":"
50
+ pad(currentdate.getSeconds());
51
console.log('['+datetime+'] '+msg);
52
} else {
53
// TODO: maybe add a callback to BeEF server for debugging purposes
54
//window.alert(msg);
55
}
56
},
57
58
/**
59
* Adds a function to execute.
60
* @param: {Function} the function to execute.
61
*/
62
execute: function(fn) {
63
if ( typeof beef.websocket == "undefined"){
64
this.commands.push(fn);
65
}else{
66
fn();
67
}
68
},
69
70
/**
71
* Registers a component in BeEF JS.
72
* @params: {String} the component.
73
*
74
* Components are very important to register so the framework does not
75
* send them back over and over again.
76
*/
77
regCmp: function(component) {
78
this.components.push(component);
79
}
80
81
};
82
83
window.beef = BeefJS;
84
}
85
86