/pesXdecrypter

A decrypter/encrypter for Pro Evolution Soccer 2016-2020

Primary LanguageCOtherNOASSERTION

About

This is a working decrypter and encrypter for save games (including the EDIT file) generated by Pro Evolution Soccer 2016 and later.

Compiled binaries for Windows are available here on GitHub. The game version-specific libraries from previous releases were replaced by the universal pesXdecrypter library.

This project was initially developed as 'pes16decrypter' by a contributor who now wishes to remain anonymous. May he rest in peace among the fish. This fork is currently maintained by 4ccbent on GitHub. Since then, support for newer game versions and CMake has been added, along with some additional features.

Thanks go to zlac for providing simplified decryption/encryption functions, as well as additional encryption keys.

Background

All save files generated by the games mentioned above are encrypted using an interesting combination of Mersenne Twister and some kind of chained encryption key.

Each file consists of six different blocks that are encrypted differently. In the order they appear in the file, they are

  • The encryption header. This contains part of the information required to decrypt the file. This is seeded differently every time PES16 saves a file.
  • The file header. This specifies the type of file (EDIT, TEXPORT, SYSTEM etc.), the length of the remaining blocks in the file and some sort of hash/checksum (the game does not seem to care about this).
  • A thumbnail/logo. You would think this would be displayed when selecting the save state to load, but the game seems to ignore this.
  • The file description. This contains one or two strings about what is in the file, such as the name of the team. This is mainly for aesthetics, i.e. displaying the correct name when listing save states.
  • The actual save game data. This contains the team data/system settings/other things. This is probably the main thing you want to edit.
  • A serial number/version string. We do not know what this is for, but you probably should not change this.

Usage

This project comes with two command line tools per game version that do decryption and encryption, respectively, as well as a library.

To decrypt a file, run (replace XXX with the game version you are using, e.g. 16, 16myClub, or 17)

decrypterXXX input_file output_directory [master_key_file]

This will decrypt the file at input_file, split it up into different data blocks and save the resulting files into output_directory.

You can edit the decrypted files directly. After you're done, run the encrypter with

encrypterXXX input_directory output_file [master_key_file]

This will encrypt the different files from the specified output directory and merge them into a single output file that can be read by the corresponding game. Optionally, a file at master_key_file that includes a custom master key may be provided. This 64 byte key is then used for decryption/encryption, regardless of what game version the binary is meant for.

A library is provided for when you want to use the decrypter/encrypter in an external program. Please refer to src/crypt.h and src/masterkey.h for the exported symbols.

While there are still functions available that do not require a master key argument, these are considered deprecated and should not be used anymore. Instead, the functions that also take a master key argument should be used. The currently known keys are exported from src/masterkey.h.

Keep in mind that some languages like e.g. Python require libraries to be compiled in the same bit variety they are running in. That means you cannot use 32-bit versions of the libraries from 64-bit Python.

Compilation

This project is written in C; build files (such as for make) can be generated using CMake.

Make sure you have CMake and a compiler of your choice installed (we recommend MinGW-w64 for Windows). If you want to use the Visual Studio compiler, you will have to use the C++ instead of the C compiler, as this project requires C99 features that might not be present in the Visual Studio C compiler.

For convenience, Qt for Windows comes with both an IDE that supports CMake projects and MinGW-w64.

Consider adding the bin directory of both MingGW and CMake to the system path variable for everything to work from command line.

Run CMake (cmake-gui), create a build folder within the project folder, and from this build folder run configure and generate a MinGW Makefile.

Then, from within the same folder, run the following in a command line window from within the build folder:

mingw32-make

Library files and some binaries should now be built. The library is static by default. If you wish to build a shared library, enable the BUILD_SHARED_LIBRARIES option in cmake-gui or ccmake.

If you are using Linux/Unix, you should be able to compile the project without any additional dependencies. macOS is currently untested.

License

This project is released into the public domain. You are allowed to modify, redistribute and sell the code without need for attribution. Please consider contributing back to the community and releasing your code if you build on top of this project.

Please note that this license does not apply to src/mt19937ar.c, which was made available by Takuji Nishimura and Makoto Matsumoto. Please respect their license when redistributing the code or binaries.