令我感到非常遺憾的是,我不得不宣布,在可預見的將來,IL2Cppinspector的開發工作已停止。
這樣做的原因是,由於健康和個人生活的變化,我根本沒有時間去做該項目。這對我來說是非常令人沮喪的,但是我真的幾乎無能為力。
請隨意分叉該項目並進行改進!您也可以繼續發布問題,因為我想在我或其他人確實有機會重新研究此問題的情況下保存的錯誤和問題。但是請注意,我不會在可預見的未來回應問題或公關。
如果您需要IL2CPP工具,我建議我的朋友和同事的出色項目CPP2IL,它是一種正在進行的工作工具,可以將IL2CPP二進製文件直接轉換為IL代碼,可以在DNSpy中很容易查看,這是一項龐然大物的任務,所以請執行此操作,並在這個令人驚嘆的項目中支持他的工作!
快樂黑客,
凱蒂。
IL2Cppinspector可幫助您逆向工程IL2CPP應用程序,提供當前可用的最完整分析。

輸出IL2CPP類型定義,元數據和方法指針作為C#存根代碼
創建.NET組裝墊片DLL,其中包含IL2CPP應用結構和元數據,以用於諸如ILSPY,DNSpy,Unity Asset Loads AssetStudio或託管代理生成等代表層中的元數據。
在IL2CPP應用程序中為所有類型,方法,功能指針和API函數創建C ++腳手架,以在X64DBG,Cydia基板等中使用。
創建IDA和Ghidra Python腳本以填充符號,功能和鍵入信息;包括用於實現其他目標腳本的API掛鉤
直接從IL2CPP文件創建Visual Studio C ++ DLL注入項目
直接從IL2CPP文件創建Visual Studio C#代碼存根解決方案
直接從IL2CPP文件中創建使用完整的地址圖創建JSON Metadata 。
從任意C#源代碼中創建IL2CPP二進製文件,而無需統一項目
三個主要的API用於您自己的自定義靜態分析項目,以查詢低級別的二進制元數據,.NET類型模型和整個C ++應用程序。這些也可以作為Nuget軟件包使用。
插件SDK允許您創建自定義插件來擴展IL2Cppinspector的功能
擊敗某些類型的混淆
支持所有主要的文件格式和處理器架構
在Windows,MacOS X和Linux上工作。具有拖放支持的Windows用戶的集成GUI
自Unity 5.3.0以來,用IL2CPP的每一個版本進行測試
您可以在我的系列IL2CPP逆向工程中閱讀有關IL2CPP的工作方式的更多信息:
第1部分:Hello World和IL2CPP工具鏈
第2部分:結構概述並找到元數據
IL2CPPPENDER插件開發Wiki
如何創建,使用和調試IL2CPP DLL注射項目
在IL2CPP DLL注射項目中使用代碼
使用IL2Cppinspector的類型模型提取Protobuf-NET定義(案例研究:秋季傢伙)
查找混淆的Global-metadata.dat文件的加載程序 - 說明瞭如何在幾乎任何global-metadata.dat應用程序中找到加載程序,DEOBFUSCATION和/或解密代碼
啟用英雄聯盟的加載:野生裂痕 - 涵蓋XOR解密,XOR弦解,API導出腐爛解密,數據混淆二進制元數據
啟用Honkai Impact的加載(3個部分) - 涵蓋圖像中查找功能,global -metadata.dat的數據混淆,IDA分解器技術,如何編寫插件
vmprotect控制流honkai Impact中的混淆 - 涵蓋了使用X64DBG和IDA分解器從控制流扁平的函數中推出代碼路徑
逆向工程Genshin與PowerShell的影響 - 涵蓋通過蠻力攻擊 /反向模糊的編寫測試安全帶,以在摻雜的二進制中找到功能
文件格式和架構支持:
很高興有:
using必要的指令。範圍和類型名稱衝突會自動解決以生成編譯的代碼。類庫目標.NET CORE 3.1。由Visual Studio 2019建造。
注意:IL2Cppinspector不是一個反編譯器。它可以為您提供每種方法的應用程序和功能地址的結構,以便您可以輕鬆地直接跳到拆卸器中的感興趣方法。它不會嘗試恢復應用程序的整個源代碼。
git clone --recursive https://github.com/djkaty/Il2CppInspector
cd Il2CppInspector
構建CLI和Windows GUI版本:
dotnet publish -c Release
獲取所有當前插件(可選):
powershell -f get-plugins.ps1
構建CLI版本:
cd Il2CppInspector.CLI
dotnet publish -r osx-x64 -c Release
獲取所有當前插件(可選):
../get-plugins.sh
構建CLI版本:
cd Il2CppInspector.CLI
dotnet publish -r linux-x64 -c Release
獲取所有當前插件(可選):
../get-plugins.sh
對於支持.NET Core的其他操作系統,將-r xxx添加到最終命令中,其中xxx是從https://docs.microsoft.com/en-us/dotnet/articles/core/rid-catalog中刪除的。
用於命令行使用的輸出二進製文件放置在Il2CppInspector/Il2CppInspector.CLI/bin/Release/netcoreapp3.0/[win|osx|linux]-x64/publish/Il2CppInspector.exe 。
Windows GUI的輸出二進製文件放置在Il2CppInspector/Il2CppInspector.GUI/bin/Release/netcoreapp3.1/[win|osx|linux]-x64/publish/Il2CppInspector.exe 。
plugins文件夾應與Il2CppInspector.exe放置在同一文件夾中。
在命令提示符下運行Il2CppInspector.exe 。
文件格式和體系結構將自動檢測到。
默認情況下,所有輸出都是生成的。要僅生成特定的輸出,請使用--select-outputs開關與輸出選擇開關結合使用。
-i, --bin (Default: libil2cpp.so) IL2CPP binary, APK, AAB, XAPK, IPA, Zip or Linux process map text input file(s) (single file or comma-separated list for split APKs)
-m, --metadata (Default: global-metadata.dat) IL2CPP metadata file input (ignored for APK/AAB/XAPK/IPA/Zip)
--image-base For ELF memory dumps, the image base address in hex (ignored for standard ELF files and other file formats)
--select-outputs Only generate outputs specified on the command line (use --cs-out, --py-out, --cpp-out, --json-out, --dll-out to select outputs). If not specified, all outputs are generated
-c, --cs-out (Default: types.cs) C# output file (when using single-file layout) or path (when using per namespace, assembly or class layout)
-p, --py-out (Default: il2cpp.py) Python script output file
-h, --cpp-out (Default: cpp) C++ scaffolding / DLL injection project output path
-o, --json-out (Default: metadata.json) JSON metadata output file
-d, --dll-out (Default: dll) .NET assembly shim DLLs output path
--metadata-out IL2CPP metadata file output (for extracted or decrypted metadata; ignored otherwise)
--binary-out IL2CPP binary file output (for extracted or decrypted binaries; ignored otherwise; suffixes will be appended for multiple files)
-e, --exclude-namespaces (Default: System Mono Microsoft.Reflection Microsoft.Win32 Internal.Runtime Unity UnityEditor UnityEngine UnityEngineInternal AOT JetBrains.Annotations) Comma-separated list of namespaces to suppress in C# output, or 'none' to include all namespaces
-l, --layout (Default: single) Partitioning of C# output ('single' = single file, 'namespace' = one file per namespace in folders, 'assembly' = one file per assembly, 'class' = one file per class in namespace folders, 'tree' = one file per class in assembly and
namespace folders)
-s, --sort (Default: index) Sort order of type definitions in C# output ('index' = by type definition index, 'name' = by type name). No effect when using file-per-class or tree layout
-f, --flatten Flatten the namespace hierarchy into a single folder rather than using per-namespace subfolders. Only used when layout is per-namespace or per-class. Ignored for tree layout
-n, --suppress-metadata Diff tidying: suppress method pointers, field offsets and type indices from C# output. Useful for comparing two versions of a binary for changes with a diff tool
--suppress-dll-metadata Diff tidying: suppress method pointers, field offsets and type indices attributes from DLL output. Useful for comparing two versions of a binary for changes
-k, --must-compile Compilation tidying: try really hard to make code that compiles. Suppress generation of code for items with CompilerGenerated attribute. Comment out attributes without parameterless constructors or all-optional constructor arguments. Don't emit
add/remove/raise on events. Specify AttributeTargets.All on classes with AttributeUsage attribute. Force auto-properties to have get accessors. Force regular properties to have bodies. Suppress global::Locale classes. Generate dummy parameterless
base constructors and ref return fields.
--separate-attributes Place assembly-level attributes in their own AssemblyInfo.cs files. Only used when layout is per-assembly or tree
-j, --project Create a Visual Studio solution and projects. Implies --layout tree, --must-compile and --separate-attributes
--cpp-compiler (Default: BinaryFormat) Compiler to target for C++ output (MSVC or GCC); selects based on binary executable type by default
-t, --script-target (Default: IDA) Application to target for Python script output (IDA or Ghidra) - case-sensitive
--unity-path (Default: C:Program FilesUnityHubEditor*) Path to Unity editor (when using --project). Wildcards select last matching folder in alphanumeric order
--unity-assemblies (Default: C:Program FilesUnityHubEditor*EditorDataResourcesPackageManagerProjectTemplateslibcachecom.unity.template.3d-*ScriptAssemblies) Path to Unity script assemblies (when using --project). Wildcards select last matching folder in
alphanumeric order
--unity-version Version of Unity used to create the input files, if known. Used to enhance Python, C++ and JSON output. If not specified, a close match will be inferred automatically.
--unity-version-from-asset A Unity asset file used to determine the exact Unity version. Overrides --unity-version.
--plugins Specify options for plugins. Enclose each plugin's configuration in quotes as follows: --plugins "pluginone --option1 value1 --option2 value2" "plugintwo --option...". Use --plugins <name> to get help on a specific plugin
--help Display this help screen.
--version Display version information.
Apple Universal Binaries和apks/Xapks帶有多個架構的二進製文件:使用CLI時,將生成多個輸出文件,除了第一個文件名外,每個文件名在二進制中的圖像索引均由第一個後綴。不支持的圖像將跳過。
IPA軟件包:必須先解密可執行文件。不支持加密的可執行二進製文件。
拆分APK軟件包:使用CLI時,指定每個文件名之間使用逗號的APK文件列表。
由內存轉儲創建的精靈二進製文件:使用--image-base指定圖像庫(在十六進制中)。如果提供的圖像庫不正確,則應用程序可能會崩潰。
GameGuardian轉儲(和其他Linux進程映射轉儲) :您可以使用*-maps.txt文件代替IL2CPP二進製文件。 IL2CppinSpector將掃描包含地圖文件的文件夾,以自動自動匹配.bin文件並重新組裝和重新安裝libil2cpp.so 。因此,您無需手動創建文件或使用此類轉儲時提供圖像基礎地址。為此,均不得重命名文本文件和任何二進製文件,並且所有文件都必須在同一文件夾中。
包裝的PE文件(DLL) :警告:加載包裝的PE文件將導致DLL的輸入點和初始化功能執行。請勿加載惡意DLL,也不要在處理包裝的PE文件時以管理員的身份運行IL2Cppinspector。自行使用。
IL2CppinSpector可以使用指針元數據創建C#代碼存根文件,以允許您以易於閱讀的格式探索IL2CPP二進製文件。
指定-c開關以選擇C#輸出文件或路徑。
要將類型從某些命名空間中排除在C#源文件輸出中生成的類型,請在--exclude-namespaces中提供逗號分隔的case敏感名稱空間的列表。如果未指定參數,將排除以下名稱空間:
System
Mono
Microsoft.Reflection
Microsoft.Win32
Internal.Runtime
Unity
UnityEditor
UnityEngine
UnityEngineInternal
AOT
JetBrains.Annotations
向--exclude-namespaces提供一個參數將覆蓋默認列表。要輸出所有名稱空間,請使用--exclude-namespaces=none 。這僅適用於C#原型輸出。
您可以使用--layout Switch指定輸出佈局:
single文件中的所有類型namespace - 每個文件一個名稱空間(每個文件都會給出命名空間名稱)assembly - 每個文件一個彙編(每個文件都會給出彙編名稱)class - 每個文件一個類tree - 帶有頂級彙編文件夾和二級名稱空間文件夾的樹狀文件夾結構中的每個文件中的一個類您可以使用--sort開關指定內部文件類型排序:
index - 按類型定義索引排序,如IL2CPP元數據所示name - 按類型名稱按字母順序排序使用class或tree佈局時,此開關沒有效果。
當layout是class或namespace時, --flatten開關允許您縮放嵌套名稱空間的層次結構,即。一系列的子折線System/IO/Compression將是一個頂級次級子折線System.IO.Compression 。
--suppress-metadata開關使您可以抑制評論的輸出,包括方法指針,現場偏移和類型索引。當您想將兩個版本的兩個版本之間的更改分開以查看哪些類型已更改時,這很有用。
--seperate-attributes Switch指示IL2Cppinspector將彙編級屬性放在其自己的AssemblyInfo.cs文件中,而不是在每個彙編生成的第一個文件的頂部,當時layout是assembly或tree時。
只需使用-p開關運行IL2Cppinspector即可選擇IDA腳本輸出文件。將您的二進製文件加載到IDA中,按Alt+F7,然後選擇生成的腳本。在IDA分析文件時觀察輸出窗口 - 這可能需要很長時間。
IL2Cppinspector生成了三個文件,用於IDAPYTHON:PYTHON腳本本身,JSON元數據文件和C ++類型的標頭文件(如果使用CLI(如果使用cli)或il2cpp.h ,則默認情況下cpp/appdata/il2cpp-types.h如果使用了GUI)。這些文件必須存在才能使腳本成功運行。
如果您知道與哪個版本的Unity一起編譯了二進製文件,則可以通過使用--unity-version指定此功能來改進輸出,例如--unity-version 2019.3.1f1 。您還可以從應用程序中提供任何資產文件,以檢測--unity-version-from-asset統一版本。否則,IL2Cppinspector將根據二進制內容進行有根據的猜測。
IL2Cppinspector生成了IDA項目的以下數據:
應用IL2Cppinspector後IDA C ++解次數(省略為簡潔的初始化代碼):

使用-p開關運行IL2Cppinspector,以選擇GHIDRA腳本輸出文件,以及-t Ghidra (case敏感)將Ghidra指定為您想要生產的腳本類型。
IL2Cppinspector為Ghidra生成了三個文件:Python腳本本身,JSON Metadata文件和C ++類型的標頭文件。這些文件必須存在才能使腳本成功運行。
如果您知道與哪個版本的Unity一起編譯了二進製文件,則可以通過使用--unity-version指定此功能來改進輸出,例如--unity-version 2019.3.1f1 。您還可以從應用程序中提供任何資產文件,以檢測--unity-version-from-asset統一版本。否則,IL2Cppinspector將根據二進制內容進行有根據的猜測。
注意:為了獲得最佳結果,請選擇Ghidra詢問首次加載二進制時是否想執行自動分析。如果您在運行下面的腳本時收到一個Conflicting data exists at address ,請將二進製文件重新加載到項目中,然後在自動分析提示下選擇不選擇。
注意:要大大加快精靈文件的分析,請將圖像庫設置為二進制的加載選項中的零( 0x00000000 )。出於兼容的原因,在小精靈文件上執行Ghidra Python腳本將在必要時將文件的圖像庫更改為零,但是,如果當前的圖像群為非零,則可能需要很長時間才能完成。其他文件格式將保留相同的圖像庫。
將元數據進口到現有的Ghidra項目:
從代碼瀏覽器中,選擇文件 - > parse c源...
創建一個新的配置文件,並添加生成的C ++類型標頭文件。如果使用GUI,則默認情況下,這是cpp/appdata/il2cpp-types.h默認情況下是il2cpp.h 。
確保將解析選項設置為完全如下:
-D_GHIDRA_
單擊解析以進行編程並接受任何警告。這可能需要很長時間才能完成。
打開腳本管理器,然後將您在IL2Cppinspector中選擇的輸出文件夾作為腳本文件夾。
如果您已將IL2Cppinspector的腳本用於其他二進製文件,請確保python文件以不同的命名,或禁用以前的腳本文件夾的使用。
單擊“刷新”以使腳本顯示在腳本管理器中。
右鍵單擊腳本並選擇運行。這可能需要一段時間才能完成。

IL2Cppinspector為Ghidra項目生成了與IDA相同的數據 - 有關詳細信息,請參見上面的部分。
應用IL2Cppinspector後GHIDRA C ++的解說:

IL2CppinSpector生成了一系列C ++源文件,您可以通過多種方式使用它們:
使用-h開關運行IL2Cppinspector,以選擇C ++輸出文件夾。
如果您知道與哪個版本的Unity一起編譯了二進製文件,則可以通過使用--unity-version指定此功能來改進輸出,例如--unity-version 2019.3.1f1 。您還可以從應用程序中提供任何資產文件,以檢測--unity-version-from-asset統一版本。否則,IL2Cppinspector將根據二進制內容進行有根據的猜測。
您可以針對哪個您希望使用以下輸出文件的C ++編譯器:指定--cpp-compiler MSVC用於Visual Studio和--cpp-compiler GCC ,用於GCC或Clang。
IL2CppinSpector執行自動名稱衝突解決方案,以避免在C ++中使用預定義的符號和關鍵字,並處理應用程序中同名符號的重新定義。
某些IL2CPP二進製文件僅包含一組API導出,或根本沒有。在這些情況下,IL2Cppinspector將僅使用可用的出口來構建腳手架,以確保該項目成功編譯。

生成以下文件:
appdata此文件夾包含項目 - 靜脈二進制特定聲明: ilc2pp-types.h :
il2cpp-functions.h :
MethodInfo ** ) il2cpp-types-ptr.h :
Il2CppClass ** ) il2cpp-api-functions.h :
il2cpp-api-functions-ptr.h :
il2cpp_開頭的函數) il2cpp-metadata-version.h :
#define以上文件包含調試器中動態分析所需的所有數據。
此外,為DLL注入生成以下文件:
framework -Project-Nostic二進制二進制式樣板代碼和腳手架:
dllmain.cpp :
init_il2cpp() (請參見下文),並在新線程中啟動Run() (見下文) helpers.cpp and helpers.h :
helpers.h中的評論。 il2cpp-init.cpp , il2cpp-init.h和il2cpp-appdata.h :
void init_il2cpp()函數,該函數使用上述所有標頭來生成可用功能指針和類指針,這些指針和類指針映射到運行時內存映像中正確位置pch-il2cpp.cpp和pch-il2cpp.h :
appdata文件夾中所有標題的預編譯標頭(PCH) user - 特定於項目特定的二進制用戶代碼,您可以根據需要進行修改:
main.cpp和main.h :Run()函數,該函數表示您自定義注入代碼的入口點。該函數在新線程中執行,因此不會阻止DllMain 。這是唯一您應該編輯的文件夾。
對於Visual Studio用戶,還會生成以下文件:
IL2CppDLL.vcxproj , Il2CppDLL.vcxproj.filters和Il2CppDLL.sln :默認的main.cpp包含評論的代碼,以允許您使用helpers.h的功能寫入日誌或打開新的控制台。要在源代碼中指定日誌文件目標,請使用extern const LPCWSTR LOG_FILE = L"my_log_file.txt" 。
提示:發布目標應用程序的新版本時,您可以將C ++腳手架項目重新輸入。 appdata和framework文件夾將被覆蓋,但user文件夾和項目/解決方案文件將不會更改。這使得在更新目標應用程序後可以輕鬆更新您的項目!
兼容性:建議使用Visual Studio 2019(MSVC ++構建工具V142或更高版本)。腳手架項目已通過Visual Studio 2019和Visual Studio 2017(MSVC ++構建工具V141)進行了測試,但是使用Visual Studio 2017時,省略了一些輔助代碼,以使編譯能夠成功。
Il2CppDLL.sln )加載到Visual Studio中main.cpp中添加您希望在Run()函數中執行的代碼您可以訪問應用程序中的所有C#等效類型和方法,以及所有可用的IL2CPP API函數。不需要其他功能指針或類型聲明。
示例(創建Vector3並將其y坐標記錄到文件):
// in main.cpp
void Run ()
{
// Vector3 example
// (Call an IL2CPP API function)
Vector3__Boxed* myVector3 = (Vector3__Boxed*) il2cpp_object_new ((Il2CppClass*) *Vector3__TypeInfo);
// (Call an instance constructor)
Vector3__ctor (myVector3, 1 . 0f , 2 . 0f , 3 . 0f , NULL );
// (Access an instance field)
il2cppi_log_write ( to_string (myVector3-> fields . y ));
}可以在此處找到更多詳細的教程:
如何創建,使用和調試IL2CPP DLL注射項目
在IL2CPP DLL注射項目中使用代碼
IL2CppinSpector可以使用解決方案(.sln)文件,Project(.csproj)文件和彙編名稱 - namespace-class類綠色的文件夾結構來創建一個完整的Visual Studio工作區。每個項目都會創建一個單個組件。
使用--project項目開關生成解決方案工作區。
為了使IL2Cppinspector能夠創建包含正確的Unity Assembly參考的CSPROJ文件,您必須為已安裝的Unity編輯器以及現有Unity Project的項目模板或ScriptAssemblies文件夾提供路徑。
注意:默認設置將選擇Unity的最新安裝版本和默認3D項目模板的最新安裝版本,如果已安裝在默認位置中。
典型的Unity編輯器位置(用--unity-path指定): C: Program Files Unity Hub editor editor 20xx.yz
典型的Unity項目模板位置(用--unity-assemblies指定): C: Program Files Unity Unity hub editor 20xx.yz editor data resources resources packagemanager projectTemplates libcache libcache libcache libcache <name-of-template> of-template> of-template> of-template> of-template>> of-template>> of-template> of-template>
典型的Unity腳本組件在現有項目中的位置(用--unity-aseemblies指定): x: myproject liblary scriptAssemblies
用您的Unity版本編號替換X , Y和Z。將<-template>替換為所需的模板。
注意:指定這些路徑時,您可以使用Asterisk通配符(*)一次或多次。 IL2Cppinspector將以字母數字順序選擇最後一個匹配的文件夾。如果您有多個並排的Unity安裝,並且希望始終選擇最新版本或模板,這將很有用。
如果您第一次加載解決方案時,將組裝參考無法正確解決,只需關閉並重新打開解決方案即可迫使它們解決。

IL2Cppinspector可以創建一個包含有關應用程序的各種元數據的JSON文件。
使用-o開關指定JSON輸出路徑。
輸出模式如下:
addressMap (對象)
二進制中所有IL2CPP相關內容的地址圖
methodDefinitions (數組)虛擬地址,二進制符號,C ++函數簽名和.NET方法簽名在二進制中的每個.NET等效方法的簽名
constructedGenericMethods (數組)虛擬地址,二進制符號,C ++函數簽名和.NET方法簽名在二進制中的每個.NET等效混凝土通用方法的簽名
customAttributesGenerators (數組)二進制中每個自定義屬性生成器函數的虛擬地址,名稱和C ++功能簽名
methodInvokers (數組)每個方法的虛擬地址,名稱和C ++功能簽名。
統一版本低於5.3.2的stringLiterals (數組):unity版本5.3.2及以後的每個字符串的序數,名稱和文本:二進制中每個字符串的虛擬地址,名稱和文本
typeInfoPointers (數組)虛擬地址,名稱,C ++派生的類型名稱和.NET類型名稱等效的每個類定義指針( Il2CppClass * )
typeRefPointers (array)二進制中每個類型參考指針( Il2CppType * )的虛擬地址,名稱和.NET類型名稱等效
methodInfoPointers (數組)二進制中每個運行時方法定義指針( MethodInfo * )的虛擬地址,名稱和.NET方法簽名
functionAddresses (array)二進制中每個已知函數的開始的虛擬地址,包括上述所有這些功能以及上述類別中未包含的任何其他功能
typeMetadata (數組)二進制中的鍵元數據項目的虛擬地址,名稱和C ++類型名稱。這包括Il2CppCodeRegistration和Il2CppMetadataRegistration ,具體取決於二進製版本,也可能包括指向每個Il2CppCodeGenModule的指針
arrayMetadata (數組)二進制中的鍵元數據數組的虛擬地址,名稱,C ++類型名稱和大小
functionMetadata (數組)二進制中關鍵元數據函數的虛擬地址,名稱和C ++函數簽名。根據IL2Cppinspector分析二進製文件的不同,這可能包括il2cpp_codegen_register 。
apis (數組)二進制中標識的每個IL2CPP API函數的虛擬地址,名稱和C ++函數簽名
exports (數組)二進制中每個導出的虛擬地址和名稱
symbols (數組)每個命名的(非零名稱長度)的虛擬地址,名稱和符號類型和二進制中定義的非零地址函數定義,類型,字段名稱和導入(對於ELF)。當前不支持PE文件。
提供了三個PowerShell腳本,以實現易於構建和測試IL2CPP二進製文件:
il2cpp.ps1是主要的主力,並在TestSources中編譯每個指定的c#源文件(或者如果沒有提供,則全部)作為單獨的組件,並將其輸出到TestAssemblies中。然後,它將每個指定的組件中的每個指定組件都用於TestAssemblies ,並將每個架構的單獨IL2CPP項目編譯為這些架構:
將它們放在TestBinaries文件夾中。每個構建的C ++源代碼都放入TestCpp文件夾中。然後調用generate-tests.ps1 。
指定源文件的逗號分隔列表(沒有.cs擴展名)作為第一個參數(或-assemblies )處理。
您可以選擇使用第二個參數(或-unityVersion )指定Unity版本或Unity安裝路徑。如果沒有提供,則將使用最新的安裝Unity版本。您也可以指定通配符,例如。 2019*將使用Unity 2019,2018.3 2018.3*的最新安裝版本使用Unity 2018.3等的最新安裝版本。使用Unity Hub安裝所需的版本。
因此,使用一個命令,您可以為任何給定的源文件列表(每個源文件列表,每個源文件的一組輸出)生成每個架構的彙編DLL,C ++源代碼和IL2CPP二進製文件,用於指定的Unity版本。
generate-tests.ps1在Il2CppTests項目中生成一個名為Tests.cs的文件,在TestBinaries中包含一個IL2CPP項目一個測試。該文件將由Il2CppTests項目編譯。然後,您可以在Visual Studio的測試資源管理器中看到每個IL2CPP項目的一個測試。
自動生成的測試在測試中生成C#,JSON和C標頭文件中的TestBinaries中的IL2CPP二進製文件夾(每個文件名都帶有test ),並將它們(whitespace-nistersmentimentiment)與TestExpectedResults中的相應項目名稱文件進行比較。通過這種方式,您可以檢查具有已知結構的文件,以表明正在正確執行分析,或者通過對調試器中的特定二進製文件進行分析,而無需更改項目的命令行參數。
update-expected-results.ps1將所有輸出測試從TestBinaries複製到TestExpectedResults中,因此更新將用於驗證正確測試結果的文件。
示例用途:
./il2cpp.ps1
構建每個c#源文件„ nto a .net組裝dll,一個C ++源文件夾和一個IL2CPP二進制架構
./il2cpp.ps1 MyFirstTest
將MyFirstTest.cs構建到MyFirstTest.dll中,為每個受支持的體系結構創建一個名為MyFirstTest的C ++源文件夾和一個IL2CPP二進製文件
./il2cpp.ps1 MyFirstTest,MySecondTest 2019.3.1f1
使用Unity 2019.3.1f1將MyFirstTest.cs和MySecondTest.cs構建到單個組件DLL,C ++源文件夾和IL2CPP二進製文件中
./il2cpp.ps1 MyFirstTest,MySecondTest F:UnityHubEditor2019.3.1f1
如上所述,但為您的Unity安裝指定了自定義路徑。
最低支持的Unity版本是2017.1.0f3。
要了解有關這些功能的更多信息,請參見“使用IL2Cppinspector”部分的部分,以在IL2CPP逆向工程第1部分中生成IL2CPP代碼。
注意: IL2Cppinspector API也可以作為Nuget軟件包提供! (搜索:noisycowstudios.il2cppinspector)
IL2CppinSpector提供以下可重複使用的類庫API:
使用這些API輕鬆查詢IL2CPP類型,創建新的輸出模塊並將IL2Cppinspector與您自己的靜態分析應用程序集成在一起。
要在自己的項目中使用IL2Cppinspector,請添加Il2CppInspector.Common.dll的引用。
using以下指令包括以下指令:
using Il2CppInspector使用Il2CppInspector 。using Il2CppInspector.Reflection反射使用TypeModel 。using Il2CppInspector.Model使用AppModel 。有關上述更多詳細信息或教程,請參見源代碼。
應將插件放在與Il2CppInspector.exe同一文件夾中的plugins文件夾中。每個插件都應使用所需的任何依賴項或配置文件放入自己的子文件夾中。
從GUI中,您可以啟用和禁用插件,更改執行順序,並通過管理插件...按鈕配置單個插件設置。
在CLI中,您可以指定以下內容要使用的插件和設置。
對於一個插件:
Il2CppInspector.exe --plugins "myplugin --firstOption value1 --secondOption value2"
對於多個插件:
Il2CppInspector.exe --plugins "plugin1 --option1 ..." "plugin2 --option2 ..." ...
插件將按指定的順序執行。
使用CLI時始終啟用核心插件(屬於IL2Cppinspector的基本功能的核心插件),但可以在GUI中禁用。
使用CLI時,Core插件始終默認情況下首先執行。您可以通過在所需的執行順序中指定其名稱來強制核心插件以不同的順序執行。例如:
Il2CppInspector.exe --plugins "analytics --output foo.csv"
將首先運行核心插件,然後是analytics示例插件,但是:
Il2CppInspector.exe --plugins "analytics --output foo.csv" "xor"
將導致xor Core插件在analytics後運行。
要在特定插件上的幫助,請指定插件名稱而沒有參數:
Il2CppInspector.exe --plugins myplugin
要獲取更多插件,請單擊GUI中的“管理插件”窗口中獲取插件,訪問IL2CppinspectorPlugins存儲庫或使用get-plugins.ps1或get-plugins.sh腳本以更新到最新的插件釋放。

Plugins let you extend the functionality of Il2CppInspector. For example you can pre and post-process metadata and binaries to enable inspection of IL2CPP applications that Il2CppInspector cannot handle automatically.
Plugin support is currently experimental and has limited functionality.
Details on how to create your own plugins can be found in the Il2CppInspector Plugin Development Wiki.
You can find out more about plugins, and browse the source code of current plugins and examples in the Il2CppInspectorPlugins repository.
The current version of Il2CppInspector can output Python scripts targeting the IDA and Ghidra disassemblers.
When Il2CppInspector generates such a script, it generates a concatenation of a shared block of code ( Outputs/ScriptResources/shared-main.py ) which parses the JSON metadata and dispatches it to a set of implementation-specific functions to be processed, and a block of code specific to the target application which implements these functions (a file from Outputs/ScriptResources/Targets ).
If you would like to add support for a new target application, create a new Python script in Outputs/ScriptResources/Targets with the nane <target-name-without-whitespace>.py and implement the following functions:
CustomInitializer() - perform any custom initialization required for the target before applying the metadataDefineCode(code) - parse and apply the specified C++ declaration text (this is not required for Unity 5.3.2 and later; if you don't need to support earlier versions, just specify pass as the implementation)GetScriptDirectory() - retrieve the directory that the Python script is running in. This will normally be os.path.dirname(os.path.realpath(__file__))MakeFunction(start, name=None) - define address start as the start of a function, optionally with name nameSetComment(addr, text) - place the comment text at address addrSetFunctionType(addr, sig) - parse the C++ function signature in sig and apply it to the function at address addrSetHeaderComment(addr, text) - place the header/plate/pre-item comment text at address addrSetName(addr, name) - set the symbol (or label or name) of address addr to nameSetType(addr, type) - define address addr to be an item of the C++ type type Refer to the source code of IDA.py and Ghidra.py for examples.
When you add a new target and re-compile Il2CppInspector:
-t ( --script-target ) switch via the CLIIf you develop an API for a target that you think might be useful to others, please feel free to submit a PR with the code!
| Unity version | IL2CPP version | 支持 |
|---|---|---|
| 4.6.1+ | 第一版 | 不支持 |
| 5.2.x | 15 | 不支持 |
| 5.3.0-5.3.1 | 16 | 在職的 |
| 5.3.2 | 19 | 在職的 |
| 5.3.3-5.3.4 | 20 | 在職的 |
| 5.3.5-5.4.6 | 21 | 在職的 |
| 5.5.0-5.5.6 | 22 | 在職的 |
| 5.6.0-5.6.7 | 23 | 在職的 |
| 2017.1.0-2018.2.21 | 24 | 在職的 |
| 2018.3.0-2018.4.x | 24.1 | 在職的 |
| 2019.1.0-2019.3.6 | 24.2 | 在職的 |
| 2019.3.7-2019.4.14 | 24.3 | 在職的 |
| 2019.4.15-2019.4.20 | 24.4 | 在職的 |
| 2019.4.21-2019.4.x | 24.5 | 在職的 |
| 2020.1.0-2020.1.10 | 24.3 | 在職的 |
| 2020.1.11-2020.1.17 | 24.4 | 在職的 |
| 2020.2.0-2020.2.3 | 27 | 在職的 |
| 2020.2.4-2020.3.x | 27.1 | 在職的 |
| 2021.1.0-2021.1.x | 27.2 | 部分的 |
Please refer to the companion repository https://github.com/nneonneo/Il2CppVersions if you would like to track the changes between each IL2CPP release version.
If you have files that don't work or are in an unsupported format, please open a new issue on GitHub and attach a sample with details on the file format, and I'll try to add support. Include both the IL2CPP binary and global-metadata.dat in your submission.
Please check the binary file in a disassembler to ensure that it is a plain IL2CPP binary before filing an issue. Il2CppInspector is not intended to handle packed, encrypted or obfuscated IL2CPP files.
If you found Il2CppInspector useful, you can really help support the project by making a small donation at http://paypal.me/djkaty!
You can also donate with bitcoin: 3FoRUqUXgYj8NY8sMQfhX6vv9LqR3e2kzz
很多愛! - Katy
Thanks to the following major contributors!
This project uses:
Thanks to the following individuals whose code and research helped me develop this tool:
The following books and documents were also very helpful:
Pizza spinner animation in the GUI made by Chris Gannon - https://gannon.tv/
This software is licensed under AGPLv3.