Pak file compression?

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
kaiheilos
Posts: 4
Joined: Wed Jul 31, 2019 9:50 pm

Pak file compression?

Post by kaiheilos »

The game State of Decay 2 just released an update that cut the game size in half and I'm no longer able to extract the pak files using the unreal_tournament_4.bms script, hoping someone is able to help as what little modding we've been able to do is now on hold as we can't access the files. I've attached a new and old version of one of the paks in the hope someone can work out why we can no longer access them.
Please let me know if there's any other information needed to assist.
LokiReborn
Posts: 190
Joined: Fri Aug 26, 2016 3:11 pm

Re: Pak file compression?

Post by LokiReborn »

kaiheilos wrote:The game State of Decay 2 just released an update that cut the game size in half and I'm no longer able to extract the pak files using the unreal_tournament_4.bms script, hoping someone is able to help as what little modding we've been able to do is now on hold as we can't access the files. I've attached a new and old version of one of the paks in the hope someone can work out why we can no longer access them.
Please let me know if there's any other information needed to assist.


It looks like it's a LZ4 variation or something similar.
masagrator
Posts: 82
Joined: Sat Dec 22, 2018 10:03 am

Re: Pak file compression?

Post by masagrator »

Probably they updated it to Unreal Engine 4.22. You can use unrealpak from Unreal Engine 4.22 to unpack/pack .pak files. For unpacking you need to prepare cryptokey file, for packing you don't need it.
kaiheilos
Posts: 4
Joined: Wed Jul 31, 2019 9:50 pm

Re: Pak file compression?

Post by kaiheilos »

masagrator wrote:Probably they updated it to Unreal Engine 4.22. You can use unrealpak from Unreal Engine 4.22 to unpack/pack .pak files. For unpacking you need to prepare cryptokey file, for packing you don't need it.


Is there any way to create one of these files or am I SOL at the moment?

Edit: Also, is there a way to verify which version they're using currently? The exe file just has version 1.0.0

Edit 2:
LokiReborn wrote:It looks like it's a LZ4 variation or something similar.

I ran it through the quickbms comtype scan and also tried to decompress it with lz4 1.9.1 but the scan didn't give any matches and lz4 came up unknown format.
masagrator
Posts: 82
Joined: Sat Dec 22, 2018 10:03 am

Re: Pak file compression?

Post by masagrator »

You have here at the end how to prepare cryptokey file if you know the AES key ("How To Use")
https://blog.jamie.holdings/2019/03/23/ ... -projects/

I think exe should have informations about used Unreal Engine. From encrypted pak you can't determine used version. But it doesn't matter which one exactly you use. Every 4.22.x is the same in terms of unrealpak (v8).

Edit: so from what I see they don't use any encrypting. Probably they modified unrealpak configs to some custom one. So unrealpak can't unpack it with default settings.

D:\Pack\UnrealPakSwitch2>v8\2\3\UnrealPak.exe D:\Pack\UnrealPakSwitch2\pakchunk001200-UWP.pak -extract ..\..\..\
LogPaths: Warning: No paths for game localization data were specifed in the game configuration.
LogPakFile: Display: Using command line for crypto configuration
LogPakFile: Display: Added 1 entries to add to pak file.
LogFileManager: Error: Requested read of 128 bytes when 0 bytes remain (file=../../..\pakchunk001200-UWP.pak, size=1075361)
LogWindows: Error: === Critical error: ===
LogWindows: Error:
LogWindows: Error: Fatal error: [File:D:\Build\++UE4\Sync\Engine\Source\Runtime\PakFile\Private\IPlatformFilePak.cpp] [Line: 4233]
LogWindows: Error: Invalid pak file version (65539) in '../../..\pakchunk001200-UWP.pak'. Verify your installation.
LogWindows: Error:
LogWindows: Error:
LogWindows: Error:

Press any key to continue . . .


I will try to test the newest unrealpak, this was from 4.22.1, now newest is Preview 4 4.23.0

Edit2: 4.23.0 the same error. So I think they customized it.
LokiReborn
Posts: 190
Joined: Fri Aug 26, 2016 3:11 pm

Re: Pak file compression?

Post by LokiReborn »

kaiheilos wrote:
masagrator wrote:Probably they updated it to Unreal Engine 4.22. You can use unrealpak from Unreal Engine 4.22 to unpack/pack .pak files. For unpacking you need to prepare cryptokey file, for packing you don't need it.


Is there any way to create one of these files or am I SOL at the moment?

Edit: Also, is there a way to verify which version they're using currently? The exe file just has version 1.0.0

Edit 2:
LokiReborn wrote:It looks like it's a LZ4 variation or something similar.

I ran it through the quickbms comtype scan and also tried to decompress it with lz4 1.9.1 but the scan didn't give any matches and lz4 came up unknown format.


Correct, it's not a standard lz4 implementation from what it looked like, but running it will start to produce something that appears correct (I attached it for reference) which is why I said it's a variation of it.

Edit: I'd also note here comparing this against the original the starting 0x35 bytes are missing so while it does use some variate of lz4 there is more to being able to use it even if you can get the compression worked out.
kaiheilos
Posts: 4
Joined: Wed Jul 31, 2019 9:50 pm

Re: Pak file compression?

Post by kaiheilos »

LokiReborn wrote:Correct, it's not a standard lz4 implementation from what it looked like, but running it will start to produce something that appears correct (I attached it for reference) which is why I said it's a variation of it.

Edit: I'd also note here comparing this against the original the starting 0x35 bytes are missing so while it does use some variate of lz4 there is more to being able to use it even if you can get the compression worked out.

Would it be possible for a brief explanation on how you got the contents of the text file? I couldn't get the lz4 program to work on the file when I tried but I'd love to know more about it and perhaps spend some time on trying to work it out, just not really sure where to start with it.
LokiReborn
Posts: 190
Joined: Fri Aug 26, 2016 3:11 pm

Re: Pak file compression?

Post by LokiReborn »

kaiheilos wrote:
LokiReborn wrote:Correct, it's not a standard lz4 implementation from what it looked like, but running it will start to produce something that appears correct (I attached it for reference) which is why I said it's a variation of it.

Edit: I'd also note here comparing this against the original the starting 0x35 bytes are missing so while it does use some variate of lz4 there is more to being able to use it even if you can get the compression worked out.

Would it be possible for a brief explanation on how you got the contents of the text file? I couldn't get the lz4 program to work on the file when I tried but I'd love to know more about it and perhaps spend some time on trying to work it out, just not really sure where to start with it.


It's a regular lz4 implementation though I didn't use Quickbms to do it.
kaiheilos
Posts: 4
Joined: Wed Jul 31, 2019 9:50 pm

Re: Pak file compression?

Post by kaiheilos »

LokiReborn wrote:It's a regular lz4 implementation though I didn't use Quickbms to do it.

Just wanted to come back and say thank you for the information provided :) I spent a bit of time learning how quickbms works and managed to edit the unreal tournament bms to detect the lz4 compression in the files and now have them unpacked, I wouldn't have figured it out if you hadn't provided the compression type so it's very much appreciated.