Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Pak: Difference between revisions

From Trackmania Wiki
m Fix extra space in code blocks
Differentiate unencrypted and encrypted header
Line 21: Line 21:
=== From 2010 (version 6 to 18) ===
=== From 2010 (version 6 to 18) ===


Newer Pak files have an unencrypted header with various descriptive metadata about their contents. That includes:
Newer Pak files have an additional unencrypted header part with various descriptive metadata about their contents. That includes:


* SHA256 checksum of the header contents, used for comparison regarding validity and updates
* SHA256 checksum of the header contents, used for comparison regarding validity and updates
Line 30: Line 30:
* Metadata about other included Pak content
* Metadata about other included Pak content
* Custom download URL (version 13+)
* Custom download URL (version 13+)
This unencrypted header part may not be always filled. The encrypted header part with directories and files follows after it.


There are 2 types of keys used for actual decryption:
There are 2 types of keys used for actual decryption:

Revision as of 11:31, 28 January 2026

Pak (PAK, or NadeoPak) is a proprietary file format used for packaging game content in encrypted form.

Pak files cannot be opened in any standard archiver. The majority of the package is encrypted with the Blowfish cipher. Individual files are then often compressed with either zlib or LZ4 algorithms.

The primary purpose of the Pak format is to conceal parts of the GameData directory behind a secure wall, significantly limiting the modification capabilities of the official game content. The format is also effective enough for keeping the content safe from infringement.

History

In the TrackMania series, the system of NadeoPak was first introduced in the TrackMania United release (not the Forever one). It was intended to replace the StarForce protection, which was used in the previous TrackMania games, such as Sunrise and Original. The format evolved in many ways over the years, reaching up to version 18 that is currently used for both the Maniaplanet platform and in Trackmania 2020.

Structure

The structure of the Pak file is slightly different between TrackMania United Forever (up to 2008) and Maniaplanet (from 2010).

Up to 2008 (version 3)

Pak files until the release of Forever games use version 3. This version always encrypts everything in the file, including the header. The only unencrypted information is the version itself and the Blowfish initialization vector. The key used to decrypt each of these Pak files is stored in the paklist.dat file located in the Packs directory of the installation, next to the other Pak files.

Individual files are compressed using zlib.

From 2010 (version 6 to 18)

Newer Pak files have an additional unencrypted header part with various descriptive metadata about their contents. That includes:

  • SHA256 checksum of the header contents, used for comparison regarding validity and updates
  • Author of the package, their login, nickname, and zone
  • Description (comments)
  • Build information
  • Creation date
  • Metadata about other included Pak content
  • Custom download URL (version 13+)

This unencrypted header part may not be always filled. The encrypted header part with directories and files follows after it.

There are 2 types of keys used for actual decryption:

  • Header key - decrypts the list of files and directories
  • File key - decrypts the file contents

These 2 keys are formed from the base key that is either hardcoded in the game executable or resolved from an encrypted key given from the master server. The base key is then used to create the file key like this:

fileKey = md5(baseKey + "NadeoPak")

The header key is then created like this:

headerKey = fileKey ^ 0xCE591D76EBFC7DA1N90BCB6DEBBCBEE56N

Individual files are compressed using zlib up to version 17. From version 18, LZ4 is used.

Header

The header mostly contains the list of all the directories and files with their offsets that tell the computer where to start reading individual files. It also includes an MD5 hash of itself to ensure validity.

Files are often named as MD5 hashes of their original file names with a few tricks. This obfuscation is possible thanks to references to these files in the reference table of other Gbx files whose file names are not actually written as a hash. As an example, block metadata (for example, EDClassic.Gbx) doesn't use a hash as its file name, as it is being indexed by a simple directory lookup, but this Gbx file contains references to the mesh Gbx files, which do have a hash file name. The game can simply take a file reference, hash it, and do a lookup for that hash instead of the file.

From version 14+, each file info also stores an MD5 checksum of its actual contents.

File data

The rest of the Pak file is just data from all the files in concatenated form. Each file is often both compressed and encrypted, but can also be only compressed or only encrypted. You can index this data by using the file information received from the header.

For decryption, it is important to stream the file, beginning with decryption and following with decompression. It is very important to use the exact sizes of blocks as done by the game.