Padding Encryption [infuriating]

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
JohnHudeski
Posts: 40
Joined: Mon Dec 29, 2014 8:49 pm

Padding Encryption [infuriating]

Post by JohnHudeski »

So I cam across an old xbox game that uses the most annoying encryption of all time. It injects FF at seemingly random intervals (mostly 9).
I think its a zip/ pak file not too sure (Signature: DF? 50 4B 03 04 14 E9 32)
Anyone have any tips on dealing with this?
JohnHudeski
Posts: 40
Joined: Mon Dec 29, 2014 8:49 pm

Re: Padding Encryption [infuriating]

Post by JohnHudeski »

Image

I think it is a zip file but there are characters injected at fixed intervals
like 0xDF means the next one is in 9 bytes 0xFF in 8 bytes
This was my working assumption until they started potentially xoring
so it is ridiculous

I made the assumption due to the consistent nature of the padding
Allen
Posts: 156
Joined: Tue Sep 01, 2015 9:44 am

Re: Padding Encryption [infuriating]

Post by Allen »

It looks like LZSS compression. From the data after decompression, it seems that only the PK file header of ZIP is added, but there is no compression, not double compression.
Just a hint, it may not be correct.
Last edited by Allen on Wed Jan 15, 2020 4:43 am, edited 1 time in total.
JohnHudeski
Posts: 40
Joined: Mon Dec 29, 2014 8:49 pm

Re: Padding Encryption [infuriating]

Post by JohnHudeski »

That's a little confusing considering there are multiple pk headers in the file .
I'm still new to this. What tool did you use for your decompression (python is refusing to install lzss for me right now)

I tried using offzip on the file you uploaded but no luck so it is probably not a zip at all

Image
Allen
Posts: 156
Joined: Tue Sep 01, 2015 9:44 am

Re: Padding Encryption [infuriating]

Post by Allen »

I reviewed the data today and found that it is LZSS compression, but the buffer size is 1024 bytes. Not 4096.
lzss.c in the attachment can be used after compilation.
test_lzss.exe is a C # program that I ported from C.
test_lzss usage, drag directly file to the program.
You can also refer to the C source code to port to Python.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Padding Encryption [infuriating]

Post by aluigi »

BMS Script:

Code: Select all

comtype lzss "10 4 2 2 0"
get ZSIZE asize
xmath SIZE "ZSIZE * 10"
clog "output.zip" 0 ZSIZE SIZE
Allen
Posts: 156
Joined: Tue Sep 01, 2015 9:44 am

Re: Padding Encryption [infuriating]

Post by Allen »

aluigi wrote:BMS Script:

Code: Select all

comtype lzss "10 4 2 2 0"
get ZSIZE asize
xmath SIZE "ZSIZE * 10"
clog "output.zip" 0 ZSIZE SIZE

Thank you Aluigi. :D
Learned.
JohnHudeski
Posts: 40
Joined: Mon Dec 29, 2014 8:49 pm

Re: Padding Encryption [infuriating]

Post by JohnHudeski »

Wait what?