American Idol- IMAGE.DAT

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
Anexenaumoon
Posts: 119
Joined: Sun Dec 27, 2015 10:22 pm

American Idol- IMAGE.DAT

Post by Anexenaumoon »

Hey! So, I'm not a total noob in writing and reversing archives at this point, but this little portion's been stumping me.

Here's the code what I have right now for the archive:

Code: Select all

get NULL long
get FCOUNT long
get NULL long

for i = 0 < FCOUNT

get FNAMELENGTH long
getdstring NAME FNAMELENGTH
callfunction skip
get OFFSET long
get SIZE long
get NULL long
log NAME OFFSET SIZE


next i

startfunction SKIP
   do
    get NULL byte
    while NULL == 0
    savepos CUROFF
    math CUROFF - 1
    goto CUROFF
endfunction



The issue is though, that the skip function throws a script error, and that's due to the incorrect positioning of the current offset going backwards when a 0 value is included in the offset long value. I can't figure out a workaround, and could use some help if anyone could help me :P. I've included a filecutted version of the table as that's the information that's important. the location of the offset changes a certain number of bytes after the name string. Thanks for the help in advance!
~Anexenaumoon

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

Re: American Idol- IMAGE.DAT

Post by aluigi »

It's just padded/aligned data, so you have to replace "callfunction skip" with "padding 4" :)
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: American Idol- IMAGE.DAT

Post by aluigi »

Ah, FYI, the third field is probably the compressed size:

Code: Select all

get ZERO long
get FILES long
get ZERO long
for i = 0 < FILES
    get NAMESZ long
    getdstring NAME NAMESZ
    padding 4
    get OFFSET long
    get SIZE long
    get ZSIZE long
    if ZSIZE == 0
        log NAME OFFSET SIZE
    else
        clog NAME OFFSET ZSIZE SIZE
    endif
next i
Anexenaumoon
Posts: 119
Joined: Sun Dec 27, 2015 10:22 pm

Re: American Idol- IMAGE.DAT

Post by Anexenaumoon »

Oh, haha, didn't know about padding :P. Silly me, thanks as always aluigi! Turns out, it's not a compressed size, it throws an error. But, it's no issue it seems :p
Anexenaumoon
Posts: 119
Joined: Sun Dec 27, 2015 10:22 pm

Re: American Idol- IMAGE.DAT

Post by Anexenaumoon »

Sorry for the double post, the script breaks around towards the backend, and I have no clue why. Could it be that the padding changes? If you could, can you take a look at these sets of entries? I don't know if it would help, I've been trying to crack at this thing for ages and really appreciate the help. Thanks again!
entriespart2.dat
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: American Idol- IMAGE.DAT

Post by aluigi »

What's the exact error you get?
The format is correct.
Anexenaumoon
Posts: 119
Joined: Sun Dec 27, 2015 10:22 pm

Re: American Idol- IMAGE.DAT

Post by Anexenaumoon »

This is the error I get when I run the script:

Code: Select all

 offset   filesize   filename
--------------------------------------
  000d4000 212        ANIMATION\2D\COSTUME_OUTLINE_FLASHER.DAT

Error: the compressed zlib/deflate input is wrong or incomplete (-3)
Info:  algorithm   1
       offset      000d4000
       input size  0x0000003b 59
       output size 0x000000d4 212
       result      0xffffffff -1

Error: the uncompressed data (-1) is bigger than the allocated buffer (212)

Last script line before the error or that produced the error:
  14  clog NAME OFFSET ZSIZE SIZE



Could it be maybe that it's a different comtype?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: American Idol- IMAGE.DAT

Post by aluigi »

Upload that archive.
Anexenaumoon
Posts: 119
Joined: Sun Dec 27, 2015 10:22 pm

Re: American Idol- IMAGE.DAT

Post by Anexenaumoon »

It's 1.8 gb, but here it is :P I appreciate it:

https://mega.nz/#!9ssVDA4Q!g2F0npejdhRf ... KFXRrD-6Bo
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: American Idol- IMAGE.DAT

Post by aluigi »

Use this script and upload the first file it generates (the one with "_0_" in the filename):
http://aluigi.org/bms/filecutter.bms
Anexenaumoon
Posts: 119
Joined: Sun Dec 27, 2015 10:22 pm

Re: American Idol- IMAGE.DAT

Post by Anexenaumoon »

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

Re: American Idol- IMAGE.DAT

Post by aluigi »

ok the compression algorithm is lzss0:
http://aluigi.org/bms/american_idol.bms
Anexenaumoon
Posts: 119
Joined: Sun Dec 27, 2015 10:22 pm

Re: American Idol- IMAGE.DAT

Post by Anexenaumoon »

works like a charm, thanks for the help! How'd you go about knowing it was lzss0? I'm interested to see if you don't mind :P.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: American Idol- IMAGE.DAT

Post by aluigi »

Usually it works in this way, first you have to locate a file that is made with a known format or contains text strings, the VMS files were the good option.
Then you can try to recognize the format of the compressed file with some experience (take a look here) or you can opt for the comtype_scan2 solution.
If lzss works but you see a lot of 0x20 bytes with the hex editor in the decompressed file, then it's probably lzss0
Anexenaumoon
Posts: 119
Joined: Sun Dec 27, 2015 10:22 pm

Re: American Idol- IMAGE.DAT

Post by Anexenaumoon »

Ah, that makes sense. Thanks a bunch for the help.