工具:010Editor,IDA 7.5,Jadx,VS Code
样本Last Island of Survival_6.3_Apkpure.xapk
打开ida,把libil2cpp拖到ida中按快捷键Shift+F12等待字符串分析完后,搜索global-metadata.dat
VSCode打开il2cpp源代码,全局搜索global-metadata.dat
双击搜索出来的结果,切记要选il2cpp目录下的
发现
sub_57EE7C("global-metadata.dat");
就是
vm::MetadataLoader::LoadMetadataFile("global-metadata.dat");
ida中双击sub_57EE7C进入,VS code中也跳转到LoadMetadataFile函数
根据字符串特征ERROR: Could not open %s 定位到Open函数
os::File::Open(resourceFilePath, kFileModeOpen, kFileAccessRead, kFileShareRead, kFileOptionsNone, &error);
根据特征
while
v15 = 0;
v16 = 0;
v15++
^=
判断加密逻辑为根据文件的长度循环读取字节码做亦或加密
亦或值从dword_2A26E10中获取
大致加密逻辑为
int v15 = 0;
while(v15<文件流大小){
文件流[v15]^=dword_2A26E10[(v15/0x32)%50]
v15++;
}
import struct
if __name__ == '__main__':
f = open('global-metadata.dat', 'rb')
a = ""
a = f.read()
key = [0xFE, 0x98, 0xAB, 0xDE, 0x99, 0x76, 0x36, 0x33, 0xBC,
0xFE, 0xAB, 0x65, 0xAD, 0x61, 0x97, 0xBE, 0x89, 0xAB,
0xA, 0x93, 0x98, 0x8A, 0x2D, 0x93, 0x23, 0xDF, 0xB3,
0x35, 0xD, 0x32, 0x4D, 0xE2, 0xE8, 0xDB, 0xE, 0xAE,
0x8E, 0x3D, 0xA, 0xE9, 0xA8, 0xE8, 0xEB, 0x38, 0xEF,
0xBD, 0xE8, 0x9B, 0x39, 0xE9, 0, 0]
with open('global-metadata_fix.dat', 'wb') as fp:
n = 0
while n < len(a):
num = struct.unpack("