Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/extensions/admin_ui/media/javascript/ui/common/beef_common.js
1155 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 Web UI commons
9
*/
10
11
if(typeof beefwui === 'undefined' && typeof window.beefwui === 'undefined') {
12
13
var BeefWUI = {
14
15
rest_token: "",
16
hooked_browsers: {},
17
18
/**
19
* Retrieve the token needed to call the RESTful API.
20
* This is obviously a post-auth call.
21
*/
22
get_rest_token: function() {
23
if(this.rest_token.length == 0){
24
var url = "<%= @base_path %>/modules/getRestfulApiToken.json";
25
jQuery.ajax({
26
contentType: 'application/json',
27
dataType: 'json',
28
type: 'GET',
29
url: url,
30
async: false,
31
processData: false,
32
success: function(data){
33
beefwui.rest_token = data.token;
34
},
35
error: function(){
36
beefwui.rest_token = "";
37
}
38
});
39
}
40
return this.rest_token;
41
},
42
43
/**
44
* Get hooked browser ID from session
45
*/
46
get_hb_id: function(sess){
47
var id = "";
48
jQuery.ajax({
49
type: 'GET',
50
url: "/api/hooks/?token=" + this.get_rest_token(),
51
async: false,
52
processData: false,
53
success: function(data){
54
for (var k in data['hooked-browsers']['online']) {
55
if (data['hooked-browsers']['online'][k].session === sess) {
56
id = data['hooked-browsers']['online'][k].id;
57
}
58
}
59
60
if (id === "") {
61
for (var k in data['hooked-browsers']['offline']) {
62
if (data['hooked-browsers']['offline'][k].session === sess) {
63
id = data['hooked-browsers']['offline'][k].id;
64
}
65
}
66
}
67
},
68
error: function(){
69
commands_statusbar.update_fail("Error getting hb id");
70
}
71
});
72
return id;
73
},
74
75
/**
76
* Get hooked browser info from ID
77
*/
78
get_info_from_id: function(id) {
79
var info = {};
80
jQuery.ajax({
81
type: 'GET',
82
url: "/api/hooks/?token=" + this.get_rest_token(),
83
async: false,
84
processData: false,
85
success: function(data){
86
for (var k in data['hooked-browsers']['online']) {
87
if (data['hooked-browsers']['online'][k].id === id) {
88
info = data['hooked-browsers']['online'][k];
89
}
90
}
91
92
if (jQuery.isEmptyObject(info)) {
93
for (var k in data['hooked-browsers']['offline']) {
94
if (data['hooked-browsers']['offline'][k].id === id) {
95
info = data['hooked-browsers']['offline'][k];
96
}
97
}
98
}
99
},
100
error: function(){
101
commands_statusbar.update_fail("Error getting hb ip");
102
}
103
});
104
console.log(info);
105
return info;
106
}
107
};
108
109
window.beefwui = BeefWUI;
110
}
111
112