Transistor .pkg Compression (PC)

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
puggsoy
Posts: 161
Joined: Sat Dec 13, 2014 1:01 am

Transistor .pkg Compression (PC)

Post by puggsoy »

Can someone identify the type of compression used on these .pkg files?
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Transistor .pkg Compression (PC)

Post by Ekey »

puggsoy
Posts: 161
Joined: Sat Dec 13, 2014 1:01 am

Re: Transistor .pkg Compression (PC)

Post by puggsoy »

Ah, this is the compression for XNB files. What I was referring to was the compression of the .pkg files themselves, which contain the XNBs. I can tell they're compressed because the filenames near the start are broken in seemingly random places (e.g. "bin\Win\Atlases\Tracker_T.extures00" in Tracker.pkg), and also because the metadata in the XNB files says the file is much larger than it actually is.
Each file starts with these bytes:

Code: Select all

40 00 00 05 01 00


Which seems to suggest some sort of identifiable algorithm; I just can't find what it is.

That said, I do appreciate the link. I was looking for a publicly available implementation of XNB decompression :)
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Transistor .pkg Compression (PC)

Post by Ekey »

It's normal XNB file with custom header > cut him > example:

Image
puggsoy
Posts: 161
Joined: Sat Dec 13, 2014 1:01 am

Re: Transistor .pkg Compression (PC)

Post by puggsoy »

I compiled the decompressor, that doesn't work. Here, you can try it yourself. I'm pretty sure the .pkg is compressed.
puggsoy
Posts: 161
Joined: Sat Dec 13, 2014 1:01 am

Re: Transistor .pkg Compression (PC)

Post by puggsoy »

Bumping just in case someone can still figure this out?
puggsoy
Posts: 161
Joined: Sat Dec 13, 2014 1:01 am

Re: Transistor .pkg Compression (PC)

Post by puggsoy »

Bump, maybe it's possible now? Really want to extract these files.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Transistor .pkg Compression (PC)

Post by aluigi »

Just a quick test I did to not leave the thread unanswered.
I have launched the comtype_scan2 scanner against Uppercut.pkg from offsets 0, 4 and 7, then I did a "grep" to search the keyword "Microsoft" and found results in the test 26 and 371.
26 is a false positive but 371 seems correct, it's the UNKNOWN6 algorithm.
Can you check it?

Code: Select all

comtype unknown6
math OFFSET = 4
get ZSIZE asize
math ZSIZE - OFFSET
xmath SIZE "ZSIZE * 20"
get NAME basename
clog NAME OFFSET ZSIZE SIZE
Savage
Posts: 176
Joined: Thu Oct 02, 2014 4:58 pm

Re: Transistor .pkg Compression (PC)

Post by Savage »

puggsoy wrote:Bump, maybe it's possible now? Really want to extract these files.

Try this,

http://pastebin.com/TkZZKqUW

Original source:
https://www.reddit.com/r/transistor/com ... re_ripper/

The bms only works with a few files

Ekey, cutting the headers is not working with this files
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Transistor .pkg Compression (PC)

Post by aluigi »

So, basically, it's an xmemdecompress used on chunks of the file, right?
puggsoy
Posts: 161
Joined: Sat Dec 13, 2014 1:01 am

Re: Transistor .pkg Compression (PC)

Post by puggsoy »

Oh wow thanks a lot Savage, I'd kind of given up on this and forgotten about it.

The guy you linked to has some updated code here, which seems to go into a bit more detail on how to decompress the files (I think without needing .dlls from Transistor itself, and/or as many built-in XNA/MonoGame stuff). It seems to have a release, I'll try that out later today, otherwise I can maybe port what he has over to a language I can work in.

Aluigi, it appears to be something called "LZF" compression on chunks, if you go to around line 380 of this file.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Transistor .pkg Compression (PC)

Post by aluigi »

Ah like this:

Code: Select all

comtype lzf
math CHUNK_SIZE = 0x800000
math COMPRESSION_FLAG = 0x40000000
math PACKAGE_VERSION_CODE = 5
endian big
get packageHeader long
get NAME basename
log NAME 0 0
append
get PKG_SIZE asize
for OFFSET = 4 != PKG_SIZE
    get ZIP byte
    if ZIP != 0
        get CHUNK_ZSIZE long
        savepos OFFSET
        clog NAME OFFSET CHUNK_ZSIZE CHUNK_SIZE
        math OFFSET + CHUNK_ZSIZE
    else
        savepos OFFSET
        log NAME OFFSET CHUNK_SIZE
        math OFFSET + CHUNK_SIZE
    endif
    goto OFFSET
next
append
Savage
Posts: 176
Joined: Thu Oct 02, 2014 4:58 pm

Re: Transistor .pkg Compression (PC)

Post by Savage »

Aluigi, the script works like a charm, but the game doesn't work with the files unpacked, i already packed the files using this script, but the game crashes too

Code: Select all

comtype lzf_compress
get SIZE asize
get NAME basename
get EXT extension
string NAME + ".pkg"
string NAME + EXT
clog NAME 0 SIZE SIZE
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Transistor .pkg Compression (PC)

Post by aluigi »

As far as I can see from my script it requires for sure more than that lzf_compress + clog to work :)
There is clearly an header and chunks