Unity IL2CPP Reverse Engineering: A Comprehensive Guide
If you’re delving into the world of Unity game development or modding, you might have come across the term IL2CPP. Reverse engineering IL2CPP files can be a valuable skill for modders, developers, or researchers aiming to understand how Unity-powered games work under the hood. In this guide, we’ll explore the features, usage, and practical applications of the popular tool Il2CppDumper, designed to aid in reverse engineering Unity IL2CPP files. This article is for educational purposes only.
What is IL2CPP?
IL2CPP, short for "Intermediate Language to C++," is Unity’s scripting backend that converts .NET code into C++ before compiling it into native code. This enhances performance and security but also makes reverse engineering Unity games more challenging. Tools like Il2CppDumper simplify this process by restoring the IL2CPP environment to a state closer to its original .NET form.
Key Features of Il2CppDumper
Il2CppDumper is a powerful tool with several features that make it indispensable for reverse engineering Unity IL2CPP files:
- Complete DLL Restore: Restores DLL files (except code), enabling the extraction of MonoBehaviour and MonoScript.
- Wide Format Support: Supports ELF, ELF64, Mach-O, PE, NSO, and WASM formats.
- Version Compatibility: Compatible with Unity versions from 5.3 to 2022.2.
- Script Generation: Creates scripts for IDA, Ghidra, and Binary Ninja to aid in analyzing IL2CPP files.
- Structure Header File Generation: Produces a header file (
il2cpp.h
) containing structure information. - Protection Bypass: Supports Android memory-dumped
libil2cpp.so
files and bypasses simple PE protections.
Getting Started with Il2CppDumper
Installation and Setup
- Download the latest version of Il2CppDumper from its official GitHub repository.
- Extract the downloaded files into a working directory.
Basic Usage
- Run the Tool: Open
Il2CppDumper.exe
. - Select Files: Choose the IL2CPP executable file (e.g.,
GameAssembly.dll
orlibil2cpp.so
) and theglobal-metadata.dat
file. - Follow Prompts: Enter the required information as prompted by the tool.
- Output Files: The tool will generate all output files in the current working directory.
Command-Line Usage
You can also run Il2CppDumper via the command line:
Il2CppDumper.exe <executable-file> <global-metadata> <output-directory>
This will generate the same outputs as the GUI version.
Output Files
- DummyDll: Contains all restored DLL files, viewable in .NET decompilers like dnSpy or ILSpy.
- ida.py: Script for IDA to analyze IL2CPP files.
- ida_with_struct.py: IDA script that includes structure information from
il2cpp.h
. - il2cpp.h: Header file with structure information.
- ghidra.py: Script for Ghidra.
- Il2CppBinaryNinja: Script for Binary Ninja.
- ghidra_wasm.py: Ghidra script for WASM files, compatible with the ghidra-wasm-plugin.
- script.json: Metadata for the generated scripts.
- stringliteral.json: Contains string literal information.
Configuration Options
Configuration options are available in the config.json
file. Key settings include:
- DumpMethod, DumpField, DumpProperty: Toggle output of specific data in
dump.cs
. - GenerateDummyDll, GenerateScript: Enable or disable generation of DummyDll files and scripts.
- ForceIl2CppVersion: Specify a version parser for older IL2CPP versions.
- NoRedirectedPointer: Treat pointers in dumped files as unredirected (useful for certain devices).
Common Errors and Troubleshooting
Error: Metadata file supplied is not valid metadata file.
- Ensure you select the correct
global-metadata.dat
file. - Note: Some games may obfuscate metadata files for protection. Deobfuscating such files is outside the scope of Il2CppDumper.
Error: Can't use auto mode to process file, try manual mode.
- Ensure you are using the correct executable file (e.g.,
GameAssembly.dll
orlibil2cpp.so
). - If the issue persists, open a GitHub issue with the file for assistance.
Error: This file may be protected.
- Use tools like GameGuardian to dump
libil2cpp.so
from game memory. Then, process the dumped file with Il2CppDumper. - For rooted Android devices, try using Zygisk-Il2CppDumper for advanced protection bypass.
Practical Applications
Il2CppDumper is widely used for:
- Game Modding: Extract and modify Unity MonoBehaviours and MonoScripts for custom modifications.
- Debugging: Analyze Unity IL2CPP files to debug and understand application behavior.
- Research: Study the internal workings of Unity-powered applications.
Conclusion
Il2CppDumper is a versatile tool that simplifies the challenging task of reverse engineering Unity IL2CPP files. Whether you’re a developer, modder, or researcher, understanding its features and capabilities can significantly enhance your workflow. For more details, visit the official GitHub repository. Remember, use this tool responsibly and always respect intellectual property laws.
This guide is for educational purposes only. Any misuse of this tool is strictly discouraged.