public class c { public static boolean a() { for (String file : System.getenv("PATH").split(":")) { if (new File(file, "su").exists()) { return true; } } return false; }
var a =Java.use("sg.vantagepoint.a.a"); a.a.overload('[B', '[B').implementation=function(arg1,arg2){ //执行函数 var ret = this.a(arg1,arg2); //输出返回值 console.log(jhexdump(ret)); return ret; }
// owasp.mstg.uncrackable1 // hookroot检测 function hookrootuncrackable1(){ Java.perform(function () { send("hook start"); var c=Java.use("sg.vantagepoint.a.c"); //返回值改成false c.a.overload().implementation = function(){ return false; } var a =Java.use("sg.vantagepoint.a.a"); /** *重载报错 根据报错把overload添加上就可以了 * Error: a(): argument count of 0 does not match any of: .overload('[B', '[B') at throwOverloadError (frida/node_modules/frida-java-bridge/lib/class-factory.js:1020) at frida/node_modules/frida-java-bridge/lib/class-factory.js:686 at /uncrackable1.js:13 at frida/node_modules/frida-java-bridge/lib/vm.js:11 at E (frida/node_modules/frida-java-bridge/index.js:346) at frida/node_modules/frida-java-bridge/index.js:332 at input:1 */ a.a.overload('[B', '[B').implementation=function(arg1,arg2){ //执行函数 var ret = this.a(arg1,arg2); console.log(jhexdump(ret)); // console.log(byte2string(ret)); /*** * retval = this.a(arg1, arg2); password = '' for(i = 0; i < retval.length; i++) { password += String.fromCharCode(retval[i]); } console.log("[*] Decrypted: " + password); */ return ret; }
verify() ··· if (this.m.a(obj)) { create.setTitle("Success!"); str = "This is the correct secret."; } else { create.setTitle("Nope..."); str = "That's not it. Try again."; } ···
1 2 3 4 5
private native boolean bar(byte[] bArr);
public boolean a(String str) { return bar(str.getBytes()); }
最后分析到a方法最后到了bar方法是native函数里,是写在so里的,需要用IDA进行分析 解压UnCrackable-Level2.apk 到Level_02/UnCrackable-Level2/lib/armeabi-v7a文件夹中有个libfoo.so文件用IDA打开进行分析 搜索bar函数 按F5查看伪c代码 发现有个Thanks for all the fish字符串尝试输入,发现已经Success了
除了IDA还可以用Ghidra打开尝试 搜索bar函数 打开 分析代码发现有几个值进行对比 然后拼接后转字符串查看 小端序所以是倒着的 6873696620656874206c6c6120726f6620736b6e616854 使用十六进制转换工具进行查看 十六进制转换工具:https://zixuephp.net/tool-str-hex.html 选择16进制转字符串就可以了 工具:https://gchq.github.io/CyberChef 得到的结果hsif eht lla rof sknahT 最后的结果Thanks for all the fish