StriveMario / StriveMario.github.io

4 stars 1 forks source link

记一次游戏分析 | Mario #327

Open StriveMario opened 5 years ago

StriveMario commented 5 years ago

https://strivemario.work/archives/d8141220.html

记一次游戏分析

1756816846 commented 1 year ago

哥,能分享一下WriteMemoryToFile的代码吗?

StriveMario commented 1 year ago

@1756816846 哥,能分享一下WriteMemoryToFile的代码吗?

这个就俩句代码呀, var f = new File(filePath, "wb"); f.write(Memory.readByteArray(addr, length));

1756816846 commented 1 year ago

我感觉你这个思路很好,我也逆向了一个cocojs,解密文件在cocos2d::CCFileUtilsAndroid::doGetFileData执行,我hook能获取解码的内容,主要是我调用这个函数直接崩溃 我的代码 var filename = Memory.allocUtf8String("script/version.lua"); var writemod = Memory.allocUtf8String('rb'); var decrypt_f = new NativeFunction(ptr(jz), 'pointer', ['pointer', 'pointer', 'pointer','uint8',"bool"]); decrypt_f("不知道填啥", filename, writemod,0,0);

函数参数 char __fastcall cocos2d::CCFileUtilsAndroid::doGetFileData(         cocos2d::CCFileUtilsAndroid this,         const char a2,         const char a3,         unsigned int *a4,         bool a5)

------------------ 原始邮件 ------------------ 发件人: "StriveMario/StriveMario.github.io" @.>; 发送时间: 2023年2月27日(星期一) 中午1:32 @.>; @.**@.>; 主题: Re: [StriveMario/StriveMario.github.io] 记一次游戏分析 | Mario (#327)

@1756816846 哥,能分享一下WriteMemoryToFile的代码吗?

这个就俩句代码呀, var f = new File(filePath, "wb"); f.write(Memory.readByteArray(addr, length));

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

1756816846 commented 1 year ago

整个函数的算法,不太懂C语言,我判定绝对是在这里执行的解密,lua和png都是相同的加密,有一些xml是明文,在这里好像直接读了返回 char __fastcall cocos2d::CCFileUtilsAndroid::doGetFileData(         cocos2d::CCFileUtilsAndroid this,         const char a2,         const char a3,         unsigned int a4,         bool a5) {   char FileData; // r4   char *result; // r0   const char *v10; // r0   int v11; // r4   FILE v12; // r0   FILE v13; // r5   int v14; // r6   unsigned int v15; // r6   int v16; // r2   int v17; // r3   int v18; // r0   int v19; // r2   int v20; // r3   char filename; // [sp+4h] [bp-2Ch] BYREF   const char *v23; // [sp+8h] [bp-28h] BYREF   _DWORD v24[9]; // [sp+Ch] [bp-24h] BYREF

  filename = (char )a2;   v23 = a3;   v24[0] = a4;   FileData = (char )a3;   if ( !a2 )     return 0;   if ( a3 )   {     result = (char )(unsigned int8 )a2;     if ( !a2 )       return result;     (*(void (fastcall )(char , cocos2d::CCFileUtilsAndroid , const char ))((_DWORD )this + 24))(       &filename,       this,       a2);     sub_623190(&filename);     if ( filename == 47 )     {       v12 = fopen(filename, FileData);       v13 = v12;       if ( !v12 )         goto LABEL_13;       fseek(v12, 0, 2);       v14 = ftell(v13);       fseek(v13, 0, 0);       FileData = (char )operator new;       v15 = fread(FileData, 1u, v14, v13);       fclose(v13);       if ( a4 )         a4 = v15;     }     else     {       if ( a5 )       {         sub_624118(&v23, filename, (int)v24);         FileData = (char )cocos2d::ZipFile::getFileData(dword_772A3C, &v23, a4, (_DWORD )(dword_772A3C + 8), this);         v10 = &v23;       }       else       {         v11 = dword_772A3C;         sub_624118(v24, filename, (int)&v23);         FileData = (char *)cocos2d::ZipFile::getFileData(v11, v24, a4);         v10 = (const char *)v24;       }       sub_623040(v10);     }     if ( FileData )     {       if ( ((int (__fastcall )(cocos2d::CCFileUtilsAndroid ))((_DWORD )this + 92))(this) )         (((void (__fastcall )(char , unsigned int ))this + 15))(FileData, a4);       goto LABEL_16;     } LABEL_13:     sub_624118(v24, "Get data from file(", (int)&v23);     v18 = sub_623A1C((int)v24, a2, v16, v17);     sub_623A1C(v18, ") failed!", v19, v20);     FileData = 0;     sub_623040(v24); LABEL_16:     sub_623040(&filename);   }   return FileData; }

------------------ 原始邮件 ------------------ 发件人: "StriveMario/StriveMario.github.io" @.>; 发送时间: 2023年2月27日(星期一) 中午1:32 @.>; @.**@.>; 主题: Re: [StriveMario/StriveMario.github.io] 记一次游戏分析 | Mario (#327)

@1756816846 哥,能分享一下WriteMemoryToFile的代码吗?

这个就俩句代码呀, var f = new File(filePath, "wb"); f.write(Memory.readByteArray(addr, length));

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

1756816846 commented 1 year ago

大佬,又来请教了,你这份脚本还在吗,我想学习下

StriveMario commented 1 year ago

@1756816846 大佬,又来请教了,你这份脚本还在吗,我想学习下

好久前写的了, 怕是没了

1756816846 commented 1 year ago

又解决了,谢谢了

------------------ 原始邮件 ------------------ 发件人: "StriveMario/StriveMario.github.io" @.>; 发送时间: 2023年4月6日(星期四) 下午2:12 @.>; @.**@.>; 主题: Re: [StriveMario/StriveMario.github.io] 记一次游戏分析 | Mario (#327)

@1756816846 大佬,又来请教了,你这份脚本还在吗,我想学习下

好久前写的了, 怕是没了

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>