Looney Tunes Space Race .ZIP (Dreamcast)

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
lemurboy12
Posts: 265
Joined: Fri Oct 17, 2014 2:57 am

Looney Tunes Space Race .ZIP (Dreamcast)

Post by lemurboy12 »

aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Looney Tunes Space Race .ZIP (Dreamcast)

Post by aluigi »

It's a zip and so?
If you can't open it with 7-zip use my zip.bms script:
http://aluigi.org/papers/bms/zip.bms
Mygoshi
Posts: 654
Joined: Mon Oct 27, 2014 1:49 pm

Re: Looney Tunes Space Race .ZIP (Dreamcast)

Post by Mygoshi »

I think this is an archive with .zip extension but this is not the .zip know extension of WinZip. (not a zip file from WinZip, just an archive with this extension)
lemurboy12
Posts: 265
Joined: Fri Oct 17, 2014 2:57 am

Re: Looney Tunes Space Race .ZIP (Dreamcast)

Post by lemurboy12 »

yeah it's not a normal zip file
puggsoy
Posts: 161
Joined: Sat Dec 13, 2014 1:01 am

Re: Looney Tunes Space Race .ZIP (Dreamcast)

Post by puggsoy »

It is mostly the same as a normal ZIP, but it appears to be missing a bunch of header information. I basically removed some lines from Luigi's original zip.bms script that he linked to and modified some other lines. The rest is all unchanged from his original script.

Code: Select all

# Looney Tunes Space Race .ZIP (Dreamcast)
#
# This is a very slightly modified version of aluigi's original zip archive script: http://aluigi.altervista.org/papers/bms/zip.bms
# Modified by puggsoy, most of the credit goes to aluigi
# script for QuickBMS http://quickbms.aluigi.org

set ZIP_SIGN short 0x0403
goto 0
getdstring ZIP_CENTRAL_SEARCH 6 # PK_sign + sign + ver
goto 0
get zip_filesize asize
for offset = 0 < zip_filesize
    #idstring "PK\x03\x04"
    get PK_sign short       # so it works also with modified ZIP files!
    get sign short
    if sign == ZIP_SIGN     # Local file header
        get ver             short
        get flag            short
        get method          short
        get modtime         short
        get moddate         short
        get crc             long
        get comp_size       long
        get uncomp_size     long
        get name_len        short
        get extra_len       short
        getdstring name     name_len
        getdstring extra    extra_len
        savepos offset

        # zip64
        if extra_len >= 20
            getvarchr extra_id extra 0 short
            if extra_id == 0x0001
            if comp_size == 0xffffffff
                getvarchr uncomp_size 4 longlong
                getvarchr comp_size 12 longlong
            endif
            endif
        endif

        # possible lame tricks used by games
        if comp_size & 0x80000000 # < 0
        if comp_size u> zip_filesize
            math comp_size ^= 0xffffffff
            math uncomp_size ^= 0xffffffff
        endif
        endif
        if name_len & 0x80000000 # < 0
            math name_len ^= 0xffffffff
        endif
        if extra_len & 0x80000000 # < 0
            math extra_len ^= 0xffffffff
        endif

        if flag & 1
            if ZIP_PASSWORD == ""
                print "the file is encrypted, you must set ZIP_PASSWORD in the script"
                #cleanexit
            endif
            encryption zipcrypto ZIP_PASSWORD 1
        endif
        if method == 0
            Log name offset uncomp_size
        else
            if method == 8
                ComType deflate
            elif method == 1
                ComType shrink
            elif method == 6
                ComType explode
            elif method == 9
                ComType deflate64
            elif method == 12
                ComType bzip2
            elif method == 13
                ComType XMemDecompress
            elif method == 14
                ComType lzmaefs
            elif method == 21
                ComType XMemDecompress
            elif method == 64
                ComType darksector
            elif method == 98
                ComType ppmd
            elif method == 99
                print "this script doesn't support AES encryption"
                cleanexit
            else
                print "unsupported compression method %method%"
                cleanexit
            endif
            CLog name offset comp_size uncomp_size
        endif
        if flag & 1
            encryption "" ""
        endif

        math offset += comp_size
        goto offset

    elif sign == 0x0806     # Archive extra data record
        get extra_len       long
        getdstring extra    extra_len

    elif sign == 0x0201     # Central directory structure
        get ver_made        short
        get ver_need        short
        get flag            short
        get method          short
        get modtime         short
        get moddate         short
        get crc             long
        get comp_size       long
        get uncomp_size     long
        get name_len        short
        get extra_len       short
        get comm_len        short
        get disknum         short
        get int_attr        short
        get ext_attr        long
        get rel_offset      long
        getdstring name     name_len
        getdstring extra    extra_len
        getdstring comment  comm_len

    elif sign == 0x0505     # Digital Signature
        get sign_len        long
        getdstring sign     sign_len

    elif sign == 0x0606     # Zip64 end of central directory record
        get dir_record      longlong
        get ver_made        short
        get ver_need        short
        get num_disk        long
        get num_disk2       long
        get tot_entries     longlong
        get tot_entries2    longlong
        get central_size    longlong
        get central_offset  longlong
        print "Error: zip64 extensible data sector not implemented, contact me"
        cleanexit

    elif sign == 0x0706     # Zip64 end of central directory locator
        get start_central   long
        get end_central     longlong
        get disks           long

    elif sign == 0x0605     # End of central directory record
        get disk_num        short
        get disk_start      short
        get central_entries short
        get central_entries short
        get central_size    long
        get central_offset  long
        get comm_len        short
        getdstring comment  comm_len

    elif sign == 0x0807     # Data Descriptor
        get crc             long
        get comp_size       long
        get uncomp_size     long

    elif sign == 0x3030     # disk spanning
        # nothing?

    else
        # A ZIP archive should be read from the end and not sequentially because in some rare cases
        # we may have some "gaps" between the various directories, this is a basic way to guess
        # the beginning of the next directory

        # ZIP_CENTRAL_SEARCH contains zeroes that will not be considered, not a problem
        print "...search ZIP signature..."
        findloc NEW_OFFSET binary ZIP_CENTRAL_SEARCH ""
        if NEW_OFFSET == ""
            xmath COVERAGE "offset / (zip_filesize / 100)"   # "(offset*100)/zip_filesize" may go in overflow on 32bit
            set COVERAGE_OK string "not fully covered, lot of data remaining"
            if COVERAGE >= 90
                set COVERAGE_OK string "fully covered, probably no remaining data"
            endif
            print "\nError: unknown ZIP signature %sign|x% at offset %offset|x%\n       if the other files have been extracted correctly it's all ok,\n       maybe this is just the end of file:\n\n       OFFSET   %offset|x%\n       ZIP SIZE %zip_filesize|x%\n       COVERAGE %COVERAGE% / 100   (%COVERAGE_OK%)"
            cleanexit
        endif
        goto NEW_OFFSET
    endif
    savepos offset
next