Unpacking Castle Crashers Remastered Game Files


Disclaimer

The information included in this post is for educational purposes only. Any material on this webpage may not be reproduced, retransmitted, or redisplayed other than for personal or educational use.

Introduction

File signatures, also known as "magic numbers", are crucial for file identification and analysis. These unique sequences of bytes are located at the beginning of a file and are typically represented as hexadecimal values. The hex signature for Castle Crashers Remastered's game files is 50 4B 03 04 (ASCII: PK..), the version is 14 00 = 0x14 = 20 → 2.0, the data is not encrypted, and the data is not compressed. The "trailer", also known as the file footer, for these files is filename 50 4B 17 characters 00 00 00, where a character is defined as a byte. Using this information, it can be determined that the file format for Castle Crashers Remastered's game files is the PKZIP archive file. When unzipped, they resolve into .COK6.NREC files. You can learn more about PKZIP archive files here.

Instructions

The following is a list of instructions required to unpack Castle Crashers Remastered's game files:

1. Visit https://www.python.org/downloads/ and left-click on the appropriate download link.

2. Head to the location of the completed download and run the Python Setup for whichever version of Python you downloaded. Ensure that you have "Add python.exe to PATH" checked. Left-click on "Install Now".

3. Visit https://pypi.org/project/blowfish/#files and left-click on "blowfish-0.6.1.tar.gz".

4. Head to the location of the completed download and extract the contents of the compressed (zipped) folder "blowfish-0.6.1.tar" into the directory of your choice.

5. Visit this URL and left-click on the "Download raw file" icon. Save the Python script into the directory of your choice.

6. Visit https://github.com/jindrapetrik/jpexs-decompiler/releases and left-click on the appropriate download link.

7. Head to the location of the completed download and run the JPEXS FFDec Setup for whichever version of JPEXS Free Flash Decompiler you downloaded. Install JPEXS Free Flash Decompiler.

8. Create a new folder. Drag both "blowfish.py" (in the "blowfish-0.6.1.tar" folder from steps 3 and 4) and "decrypt_asset.py" (from step 5) into this folder.

9. Create two new folders (one to hold .pak files and another to store the output of any commands concerning the .pak files) within the new folder that you created in step 8. You can name them whatever you want, but I chose to name them "paks" and "unpak".

10. Head to the location of Castle Crashers Remastered's local files and copy all the .pak files from the "\data\game" subdirectory. Paste these files into the "paks" folder that you created in step 9.

11. Return to the directory that contains both "blowfish.py" and "decrypt_asset.py". Clear the File Explorer address bar, type "cmd" into it, and press the "Enter" key to open Command Prompt in that directory.

12. You will need to type the following into Command Prompt in order to unpack a particular .pak file:

python decrypt_asset.py <paks folder>/<filename>.pak <output folder>

13. For example, to unpack "main.pak", you would type the following into Command Prompt and press the "Enter" key:

python decrypt_asset.py paks/main.pak unpak

14. After you do this, you will see that both "MAIN.swf" and "MAIN.swf.raw" were generated in the "unpak" folder. "MAIN.swf.raw" is not significant, so you may delete it. This leaves only "MAIN.swf".

15. You can now use JPEXS Free Flash Decompiler to open and read "MAIN.swf".

Additional Resources

Visit this URL to access modding resources for Castle Crashers.