Technique:Reverse engineering game save files
Appearance
| On this wiki | Facts · Code · Notes · Topics |
|---|
How to work out the format of a game's save file: find where it is written, diff saves that differ in one setting, tell compression, encryption, checksums and a serialization framework apart, and check whether the format is a known family.
Overview
A save file is usually one of: a standard serialization (see the table), a game-specific struct dump with a checksum, or either of those wrapped in compression or encryption. Work from the outside in.
Steps
- Find the file. Look in the game's folder, the per-user application data folders and, for Unity, the registry or plist (Library:Unity/PlayerPrefs). Watching which file is written when you save (a file-system monitor) is quicker than guessing. Consoles and emulators keep battery saves as raw memory images (see the Pokemon save pages).
- Look at the first bytes and the strings. A readable magic or a class name identifies a framework at once (table below). Text formats (JSON, XML, INI, base64) are obvious; for base64 decode first.
- Estimate entropy. Near-random data is encrypted or compressed; structured data with long runs of zeros is not. For compressed data try the stream magics in Technique:Identifying compression libraries in binaries at the start and after a short header; size fields just before the stream often hold the uncompressed length.
- Make a minimal diff: save, change one thing (gold +1, one setting), save again, compare byte by byte. A few changed bytes point to the value; many changed bytes mean encryption, compression or a changed checksum. Keep a copy of each state.
- Find the checksum. If changing a value makes the game reject the file, a checksum or hash covers it: see Technique:Identifying checksums in file formats. Look at the last or first bytes first.
- Find the serialization framework in the game's code (strings like BinaryFormatter, Marshal, store_var, SaveGame) and read the loader; the fields come in the order the loader reads them.
- Single-player save editing only: do not touch saves of online or competitive games.
Known save families
| Start of file | Format |
|---|---|
GVAS |
Format:Unreal Engine SaveGame (GVAS) |
04 08 |
Format:Ruby Marshal (RPG Maker XP/VX/Ace) |
00, any 8 bytes, then 01 00 00 00 00 00 00 00 (usually 00 01 00 00 00 FF FF FF FF 01 00 00 00 00 00 00 00) |
Format:NRBF (.NET BinaryFormatter stream) (Unity, .NET) |
80 02 to 80 05 |
Format:Python pickle (Python games; the log inside a Ren'Py save)
|
PK 03 04, file name ending -LT1.save, entries log, json, renpy_version |
Format:Ren'Py save file |
47 44 45 43 (GDEC) |
Godot encrypted file, AES-256-CFB: Format:Godot variant binary encoding#Encrypted files |
PK 03 04 |
Format:ZIP container |
| no magic, 32-bit header with a small type byte | Format:Godot variant binary encoding |
MDB0 after decryption |
Format:Earth Defense Force save file (MDB0) |
| plain text key=value, JSON, XML | PlayerPrefs files, Godot ConfigFile, many indie games |
Pitfalls
- A checksum may cover the file except its own field, or a salt (device id, constant); compare more than one pair of saves.
- Floats and integers differ only in a byte or two between states: compare as hex and as IEEE values.
- Unverified: Steam Cloud and console save wrappers add their own headers; strip them before analysis.