从游戏中解密 Lua 文件

逆向工程 艾达 C++ 解密 游戏黑客 路亚
2021-07-04 23:26:33

我正在努力从 cocos2dx 游戏(对于 wiki)解密 LUA 脚本。

游戏文件链接: libhellolua.so(cocos2dx 外部库) 示例加密的 LUA 脚本(*.abc 文件)

我正在阅读 IDA Pro 中的图书馆。这个库没有提到“xxtea”。

我发现函数 getEncyptedFileData: pastebin getEncyptedFileData

这个功能在 Cocos2d-x 的原始源码中是没有的。我认为这个函数与解密有关(因为这个函数是用变量“*.abc”在附近调用的)。我无法理解此函数中的某些行:

1:我认为这个函数是CCFileUtils:getFileData。

v5 = (_BYTE *)(*(int (__fastcall **)(cocos2d::CCFileUtils *, const char *, const char *, unsigned int *))(*(_DWORD *)this + 16))(this, a2, "rb", &v26);

2:这个循环不可读。在这个循环中使用第一行的结果。

do
  {
    v6[(signed int)v17 * (signed __int64)v11 % (unsigned __int64)v14] = *(_BYTE *)(v13 + v16) ^ v15[v17];
    ++v17;
    v16 = (v16 + 1) % v10;
  }
  while ( v17 < v14 );

3:函数getEncyptedFileData返回这一行的结果:

v19 = (*(int (__cdecl **)(cocos2d::CCFileUtils *, _BYTE *))(*(_DWORD *)v21 + 24))(v21, v6);
1个回答
  v5 = (_BYTE *)(*(int (__fastcall **)(cocos2d::CCFileUtils *, const char *, const char *, unsigned int *))(*(_DWORD *)this + 16))(
                  this,
                  a2,
                  "rb",
                  &v26);

这是一个带有符号 xxtea 加密的签名rb现在您需要在this方法中找到 xxtea 加密密钥您可以从CCFileUtilsAppDelegate(如本文:https : //boards.libre.io/threads/decrypt-xxtea-block-cipher-in-lua-file-from-cocos2d-lua-games.297552 / )

另一种方法(我最喜欢的方法)是使用 frida 并挂钩该方法,this使用本指南打印出(arg[0]):https : //boards.libre.io/threads/decrypting-lua-files.238916/