publicclassMainActivityextendsc{ private CodeCheck m;
static { System.loadLibrary("foo"); }
publicMainActivity(){ super(); }
privatevoida(String arg5){ AlertDialog v0 = new AlertDialog$Builder(((Context)this)).create(); v0.setTitle(((CharSequence)arg5)); v0.setMessage("This in unacceptable. The app is now going to exit."); v0.setButton(-3, "OK", new DialogInterface$OnClickListener() { publicvoidonClick(DialogInterface arg2, int arg3){ System.exit(0); } }); v0.setCancelable(false); v0.show(); }
$ frida -U 3844 ... Failed to attach: unable to access process with pid 3844 due to system restrictions; try `sudo sysctl kernel.yama.ptrace_scope=0`, or run Frida as root
其实这里改为x86_64有多个原因: (1)Mac上即使在radare2中输入e asm.bits=16也不能正常按thumb模式反汇编,在Ubuntu上能正常反汇编。 (2)正常反汇编arm的so文件看不到函数的名字,不知道调用了什么函数。 (3)后面frida hook native函数的时候,arm和x86都会有”Error: unable to intercept function at ***”的错误,只有x86_64能正常hook。不知道是不是这些开源软件在Mac上都有各种各样的bug,还是我用的不对。
$ frida -U -f sg.vantagepoint.uncrackable2 -l uncrackable2.js --no-pause ... Spawned `sg.vantagepoint.uncrackable2`. Resuming main thread! [*] Starting script [USB::Android Emulator 5554::['sg.vantagepoint.uncrackable2']]-> [*] Hooking calls to System.exit [*] System.exit called
等到出现[*] Hooking calls to System.exit,点击OK,程序就不会退出了。
程序需要输入一个字符串,需要继续分析MainActivity:
1 2 3 4 5 6
this.m = new CodeCheck(); ... if (this.m.a(string)) { Dialog.setTitle((CharSequence)"Success!"); Dialog.setMessage((CharSequence)"This is the correct secret."); }
frida -U -f sg.vantagepoint.uncrackable2 -l uncrackable2.js --no-pause ... Spawned `sg.vantagepoint.uncrackable2`. Resuming main thread! [*] Starting script [USB::Android Emulator 5554::['sg.vantagepoint.uncrackable2']]-> [*] Hooking calls to System.exit [*] Intercepting strncmp [*] System.exit called [*] Secret string at 0x7fff9553d870: thanks for all the fish
输入字符串”01234567890123456789012”按VERIFY,终端会显示正确答案:Thanks for all the fish reference 利用FRIDA攻击Android应用程序(三)