This was a major overhaul to the popular tool with an entire rewrite of how the trainer files are handled from their original format. That said, I decided to just rewrite my tool specifically for Cheat Engine 6 and use a separate one for older files.
As of today, Cheat Engine is now at version 6.4 and through the 4 major revisions the sub-set of changes have altered the trainer files and their method of being saved numerous times. In total there are two major ways the files are saved based on the version of Cheat Engine being used to create them. There is also two ways a trainer can be saved and protected:
- As a stand-alone .exe file.
- As a compiled/protected .CETRAINER file that Cheat Engine understands how to read.
Each of these methods have their own ups and downs. Keep in mind though, Cheat Engine is open source so these protections are mainly just to deter newbies from editing credits and claiming they wrote something they didn't. So this post should not be seen as anything major or hard-core in terms of creating a dumping tool as the source is freely available.
Stand-Alone Executable File (.exe)
- Using this approach, trainer makers can create a stand-alone solution within Cheat Engine that actually does a few things pretty interesting for the user and makes their trainer able to make use of Cheat Engine fully. When Cheat Engine generates a stand-alone executable it does the following steps:
- The users cheat table is compressed with zlib.
- The users cheat table is then xor encrypted multiple times.
- Cheat Engine creates a new SFX file for the trainer using a base exectuable.
- Cheat Engine builds an archive file that contains the various files that this trainer will need to run.
- Cheat Engine injects this new archive into the SFX file's resources and names it 'ARCHIVE'.
- Cheat Engine injects another resource named 'DECOMPRESSOR' into the files resources which is used to extract the 'ARCHIVE' resource.
- Cheat Engine finalizes the image and renames it to the trainer creators desired name.
- cheatengine-i386.exe / cheatengine-x86_64.exe
Once the files are extracted, if a .CETRAINER file is found in the archive, the decompressor will launch the Cheat Engine executable with the trainer file as the 2nd argument. Then the following information for loading a .CETRAINER file comes into play.
- CETRAINER files can come in two manners, protected and unprotected. These files are simple .xml files that hold the Cheat Table information. If protected, the files are compressed and encrypted via a simple xor encryption.
The flow of how these files are loaded follows:
- Cheat Engine loads the file.
- Checks if the file is already xml by seeing if '<?xml' exists as the first 5 characters.
- If '<?xml' exists, just load the table as normal.
- If not, then the file is considered protected and must be decoded.
- The first layer of protection is a 3-way xor encryption.
- The first wave is a before-key relationship where the the first byte (x) starts at 2 and the first xor key starts at x-2.
- The second wave is an after-key relationship where the first byte (x) starts at length-2 and the first xor key starts at x+1.
- The last wave is a static-incrementing key relationship where the key starts at 0xCE and increments each xor.
- Next the newly xor'd data is then decompressed using zlib.
- Old Decompress Method
- Using older trainer files have no special compression or buffer, the entire buffer is assumed to be compressed and can be processed.
- New Decompress Method
- Using newer trainer files will show a 5 byte header saying 'CHEAT'. This should be skipped before attempting to decompress the buffer.
- Next the newer files also have the compressed data size after the 'CHEAT' header which should be read and used to know how much data to read and inflate from the compressed data stream.
- At this point the .CETRAINER file should be clean .xml text and can be reused/edited/etc. again.
- Is this a secure method of protection? No not at all, but it is not meant to be. It is, again, meant to deter the newbies from stealing work of others. Overall this is more of a compression method to help reduce the size of the compiled trainer. Granted, due to the fact that .exe trainer files include Cheat Engine's core files to work, the file size of trainers are fairly large with little to no cheats added. A base trainer could be around 3-5MB which is a bit excessive but due to how it works, is very nice for the user given they have full access to CE then.
For those looking to really protect their trainer / work and do not want it to be seen by others so easily, I do not recommend making your trainers in Cheat Engine, and if you do, you should use an additional packer/protector on top of what Cheat Engine does. Another thing you can do is download Cheat Engines source code and modify the code to implement other methods of protection on top of whats already there. It can help in the long run to protect things.
Keep in mind though, if your trainer does anything with WriteProcessMemory / ReadProcessMemory it can be easily 'spied' on and stolen still!
Because of needing to check files often like I mentioned above, I wrote a tool to dump the trainer files easily.
A simple drag-and-drop interface can be used to dump any trainer file made with Cheat Engine that is not modded from the original protection setup.
I will probably release this tool in the near future since others may find it useful to keep themselves protected against malicious trainer files from Cheat Engine.