Repository navigation
Open
Labels
area: nativeNative analysis and decompilation, including Ghidra, IDA, and Hopper analysis behaviorenhancementNew feature or requestprovider: il2cppAnalysis provider / engine: il2cpp
Description
Current limitation
REA currently classifies Unity artifacts through shallow surface heuristics:
- Matching
UnityEngineorUnityEngine.*assembly references in managed .NET inspection (src/dotnet/ManagedArtifactInspector.ts), marking the runtime family asunity-mono. - Matching filename segments (
libunity.soon Android orUnityFramework.frameworkon iOS/macOS), tagging the runtime convention asunityorunity-convention.
However, modern real-world Unity applications across Windows, Android, iOS, macOS, and WebGL predominantly use the IL2CPP scripting backend (or Mono CIL). For these targets, REA cannot currently recover:
- IL2CPP Metadata & Function Symbols: In an IL2CPP build, C# scripts are transpiled to C++ and compiled into native executables (
GameAssembly.dll,libil2cpp.so, or Mach-O binaries). High-level method names, types, properties, and field layouts are stripped from the native binary and stored separately inglobal-metadata.dat(usually inData/Managed/Metadata/or APKassets/bin/Data/Managed/Metadata/). In REA's Ghidra/Rizin workflows, these functions remain anonymous subroutines (FUN_1800...), making automated agent reasoning and reverse engineering tedious. - Unity Serialized Files (.assets) & AssetBundles: Game logic, configuration data, API endpoints, encryption keys, and scene graphs are stored in Unity proprietary serialized files (
.assets,sharedassets*.assets,level*) andAssetBundlearchives (LZ4/LZMA compressed). REA currently has no parser forSerializedFileheaders, TypeTrees, or Object Tables. - MonoBehaviour & Component Topology: In both Mono and IL2CPP builds, GameObject hierarchies and MonoBehaviour component bindings (linking serialized
m_Scriptpointers to C# classes) cannot be mapped.
Proposed outcome
Introduce dedicated Unity reverse engineering and extraction capabilities into REA, partitioned into modular, static analysis layers:
1. IL2CPP Metadata Recovery & Native Symbol Hydration
- Metadata Parser: Implement a safe, inert parser for
global-metadata.datsupporting metadata versions 24 through 31+ (covering Unity 2018 through 2023 / Unity 6). Extract:- String literals and field default values.
- Type definitions (namespaces, class names, interfaces, attributes).
- Method definitions (method names, return types, parameter signatures, generic instances).
- Field definitions and memory offsets.
- RVA & Method Table Correlation: Correlate metadata method indices with the code registration tables (
g_CodeRegistration/g_MetadataRegistration) inGameAssembly.dll,libil2cpp.so, or Mach-O binary to recover exact Virtual Addresses (RVAs) for all methods. - Provider Hydration (Ghidra / Rizin): Automatically feed recovered symbols, method signatures, parameter dossiers, and
Il2CppClassstruct definitions into the headless provider analysis database.- Native functions recovered through
inspect_native_functionsreceive their qualified C# names (e.g.AssemblyCSharp.PlayerController$$Awake). - Native data types recovered through
inspect_native_data_typereceive typed field layouts with accurate offsets.
- Native functions recovered through
- Synthetic Symbol Export: Optionally produce C# dummy assembly headers or JSON symbol maps (
script.json/il2cpp.h) for external inspection.
2. Unity Serialized File (.assets) & AssetBundle Extraction
- SerializedFile & AssetBundle Readers: Add inert parsers for Unity serialized containers (
SerializedFileformat versions 9-22+) and AssetBundle archives (supporting uncompressed, LZ4, and LZMA chunks with bounded decompression memory budgets). - TypeTree Reconstruction:
- When TypeTree metadata is embedded in the
.assetsfile, decode serialized structures (e.g.,TextAsset,Transform,GameObject,MonoBehaviour) into structured JSON observations without executing code. - When TypeTree is stripped (standard in production builds), correlate Class IDs (
m_ClassID) and script hashes with recovered IL2CPP / Mono class schemas to re-synthesize field layouts.
- When TypeTree metadata is embedded in the
- Artifact Exposure: Expose extracted configuration assets, embedded strings, remote API URLs, network endpoints, and third-party SDK configurations (Firebase, AppsFlyer, Photon, etc.) as first-class analysis evidence.
3. Scene & GameObject Hierarchy Mapping
- Reconstruct the parent-child scene graph from
GameObjectandTransformrecords. - Map serialized
MonoBehaviourcomponents to their underlying script definitions (m_Script), identifying active gameplay, networking, and telemetry controllers. - Parse serialized
UnityEventlisteners to trace user-interaction and trigger callbacks directly to target method names.
4. Managed Mono Backend (Assembly-CSharp.dll) Enhancement
- For classic Mono deployments, expand REA's
src/dotnet/inspector to decompile and extract structured CIL method bodies, properties, and embedded resource blobs fromAssembly-CSharp.dll.
Safety Boundaries & Error Handling
- Inert Analysis: All parsing remains non-executing and offline; no native code or Unity engine runtime is loaded or executed.
- Decompression Bombs & Resource Caps: Enforce strict byte, depth, and entry limits on AssetBundle LZ4/LZMA expansion and TypeTree depth to protect against malformed or malicious inputs.
- Obfuscation & Encryption Detection: When
global-metadata.dathas an invalid magic number (not0xFAB11BAF) due to XOR encryption, packer shuffling (e.g., Medusa, Beebyte, ArmDot), or custom loaders, return typed, actionable diagnostics (metadata_encryptedorunsupported_format) with offset and header findings rather than unhandled exceptions.
Acceptance Criteria
- Automatically classify artifacts as
unity-il2cpporunity-monoacross PE, ELF, Mach-O, and Android APK/AAB inputs. - Parse valid
global-metadata.datfiles headless in REA without requiring manual external GUI tooling (such as Il2CppDumper or AssetStudio). - Successfully resolve method pointers and annotate function symbols in Ghidra/Rizin test fixtures.
- Provide structured asset extraction for
.assetsandAssetBundlefiles with verifiable SHA-256 evidence integrity. - Define explicit failure contracts for stripped, encrypted, or unsupported metadata versions.
- Include unit and integration tests using bounded synthetic Unity fixtures.
Related
- [Feature] Recover .NET NativeAOT metadata in Ghidra workflows #743 [Feature] Recover .NET NativeAOT metadata in Ghidra workflows
- [Feature] Inspect recovered native data types and layouts #492 Inspect recovered native data types and layouts
- Add mobile application investigation providers and workflows #41 Add mobile application inspection
Metadata
Metadata
Assignees
Labels
area: nativeNative analysis and decompilation, including Ghidra, IDA, and Hopper analysis behaviorenhancementNew feature or requestprovider: il2cppAnalysis provider / engine: il2cpp
Activity
8rulerstar commentedon Oct 20, 2026
For anyone following the IL2CPP and Mono parts, the related PRs so far:
--ghidra-seeds).inspect_managed_membersfor Unity Mono script assemblies), fix(il2cpp): report a magic without a complete version as a truncated header #5726 (truncated metadata header error).Unity Mono builds already work through the existing managed tools (
inspect_managed_artifact,inspect_managed_members).matbrgz commentedon Oct 20, 2026
A small neutral fixture for the prepared SerializedFile inventory slice of this request. This is a support qualification for REA 6.7.0, not a regression report.
The generated carrier is 148 bytes, SHA-256
464f2335deaeef05a440605a8a678f7db757eb838874065579e59253890a72d8. It has a 48-byte v22 header, little-endian metadata, metadata size 85, file size 148, data offset 144, and type tree disabled. It contains one type (class ID 49), one object (path ID 1), and the four opaque payload bytesDEMO. Script, external and reference-type counts are zero. It contains no application-derived bytes.Public CLI reproduction (the observed run used the locally installed, pinned 6.7.0 entrypoint):
Observed exit code: 1. Envelope:
ok: false, codetarget_unavailable, categoryunsupported_target, reasonunsupported binary format, constraintfile_format_rejected.This could serve as a minimal acceptance fixture for a first inert inventory: headers, type records, object descriptors with physical ranges/SHA, and declared references. Useful boundaries include exact metadata consumption, absolute alignment, type index versus class ID, lossless int64 path IDs, conditional script IDs, explicit version/type-tree admission, and byte/count bounds. Missing type trees should remain unknown schemas; no implicit dependency loads, object-property parsing, native execution or address linking are needed for this slice. SerializedFile v22 is a separate layout from IL2CPP metadata versions.
8rulerstar commentedon Oct 21, 2026
I tried this fixture on an unmerged branch of mine (
feat/unity-assets-v2, no PR), in case the result is useful. Released 6.7.0 and currentmainbehave as you described:inspect-artifactrejects the file withfile_format_rejected.On that branch,
rea inspect-unity-assets neutral-unity-v22.assets --format json --full-outputexits 0 and reports:serialized-fileversion 22, little-endian, metadata size 85, file size 148, data offset 144, Unity6000.0.0f1, target platform 19, type tree disabledTextAsset), no script type"1", class ID 49, offset 144, size 4It does not produce a per-object SHA-256, and
inspect-artifactstill rejects the file there.Thanks for putting the fixture together; it made this easy to check.
morluto commentedon Nov 23, 2026
Status on a real public Unity build (REA 6.10.1 at
bf913bc3dc):Cytoid/Cytoidv2.1.4200123.apk, SHA-2567116dd0b33c3c73d43cf8fd23e0a7999230eb98930931d4ac38e287098d42706(Unity 6000.0.58f2, IL2CPP, metadata v31).inspect-il2cpp-metadata(114 images, 15,771 types, 103,610 methods, 19,414 literals, about 2 s; counts match my own header parse) and paging throughinspect-analysis-view --evidence-bundle.data.unity3d(format 8) and the 117 MBdatapack.unity3d(3,479 blocks, 1.9 s).inspect-desktop-applicationon the unzipped tree identifiesunity-il2cpp.libil2cpp.solinking hits a fixed capacity ceiling ([Bug] IL2CPP --binary refuses a real Unity 6 arm64 libil2cpp.so: 559,802 relocations exceed the fixed 1 GiB pointer-index allowance #14175); LZMA AssetBundles have no readable members ([Feature] UnityFS: decode LZMA blocks, Unity's default AssetBundle compression #14176);.unitypackage/tar is refused ([Feature] Inventory tar and gzip-compressed tar archives (Linux game releases, .unitypackage) #14177); APK coverage is falselyunknown([Bug] Signed release APKs report unknown ZIP coverage because zero padding before the APK Signing Block counts as unaccounted bytes #14178); probe routing ([Bug] inspect-desktop-application: Godot candidates get no probe, and self-contained .NET games bury the app among 180+ BCL probes #14179, and a comment on [Bug] inspect-artifact routes native PE/ELF/Mach-O only to open_binary and leaves architecture null #14157).