Protect .pak file from Unpack

Did you rebuild UnrealPak tool?

Sorry for silly question…

How to rebuild UnrealPak tool ? I am unable to find UnrealPak tool.

Perhaps like Hossein747, you have Launcher version of UE4. You should obtain full source from GitHub.

I had downloaded it from Github and build the source code.

I had found “Engine\Source\Programs\UnrealPak\Private\UnrealPak.cpp” but can’t find UnrealPak tool.

UnrealPak tool is .sln file or what?

In solution tree, look for this path:
Solution / Programs / UnrealPak.
Then recompile just this project.

Thanks for Reply. I have a little bit confusion.

I had made all changes as per your suggestions and Rebuild both UE4 Engine and UnrealPak tool and package game in development.

Are there any other steps after package(.exe) ?

Is there necessary to use -encrypt for command line argument.?

No, -encrypt is not needed if you have patched UnrealPak.cpp with changes mentioned before.

I had tried all the steps…But it is not working for me.

I am using Unreal Engine 4.8.3.

Can you attached your patched AES.h and UnrealPak.cpp ?

I’ve just been through this process myself, and apart from modifying aes.h to add your AES_KEY, you also need to add:

Input.bNeedEncryption = true;

just prior to both of the:

Entries.Add(…);

function calls within UnrealPak.cpp. Then of course, compile up UnrealPak.exe and all will be well.

I’ve made everything you said but it doesn’t work.
I rebuild the project and the game after adding the define in aes.h and after adding input.bneedEncryption = true before two “entries.add” in unrealpak.cpp but when i use Umodel, i can see everything in pak file. Can you help, where can be the mistake ? Thank you.

Sorry it’s working, i didn’t delete input.bneedEncryption = bencrypt from unrealpak.cpp before adding input.bneedencryption = true. Sorry thank you for your help

Did you rebuild UnrealPak and repackaged the game?

Umodel can’t extract my .pak file, but when i try with unrealpak to extract the file, it work . Do you think that This is normal ? Thank you.

Yes of course, because you’re extracting with your UnrealPak, which has your encryption key. If you’ll try to extract pak file with original UnrealPak (for example, obtained with EpicGamesLauncher), it should fail.

Extracting with an other original version of UnrealPak works too :frowning: I don’t understand how to fix it.

,We are seeing a crash on device for IOS using this method.

After trying these steps:
Add #define AES_KEY “Some_Long_Key_String” to the AES.h file
Modify “Input.bNeedEncryption |= bEncrypt;” to “Input.bNeedEncryption |= true;”
Rebuild Engine and Project
Remove “Saved” directory at project.
Package Game

We can package the game, but the game crashes on boot. We are currently on UE4.14.
Assert:
SharedPointer.h Line 752
Assertion Failed : IsValid()

We got this to work. I didn’t read closely enough. AES_KEY is referenced in PlatformFikePak.cpp. We just had it defined in AES.cpp.

However, it only encrypts each file in the pak file so the tool can still be used to view the contents. Is there a way to obfuscate the contents of the pak file?

Tool - you mean UnrealPak? Did you try using this tool from YOUR build of the engine, or from official engine build (which don’t have any encryption set up)?

Right, I enabled encryption following the steps above and then built. I then used an unmodified version of Unrealpak to extract the contents of an encrypted pak file. The files looks like they were encrypted, but I can still see the file structure. Is there a way to hide the file names?

No, only file contents are encrypted. However, nobody denies you from making your own pak file structure - even tiny modifications in directory structures will stop official tools from working,
It is not possible to encrypt pak file directory information because encryption is specified as per-file attribute. For instance, PARAGON game uses encryption only for INI files, but not for uassets. Probably this was done taking into account performance: I believe AES is not very fast algorithm.