某企业版加固app绕过hook
发布日期:2024-05-19 浏览次数: 专利申请、商标注册、软件著作权、资质办理快速响应热线:4006-054-001 微信:15998557370
文章转自先知社区:https://xz.aliyun.com/t/13220 作者:0x0101 1、环境及背景 pixel 2 某app (***企业版加固) frida 15.1.28 2、hook绕过 启用frida并更改端口没有发现检测行为但是直接hook会闪退 打印so 调用堆栈 function hook_pthread(){ var pthread_create_addr = Module.findExportByName(null, 'pthread_create var pthread_create = new NativeFunction(pthread_create_addr, "int", ["pointer", "pointer", "pointer", "pointer"]); Interceptor.replace(pthread_create_addr, new NativeCallback(function (parg0, parg1, parg2, parg3) { var so_name = Process.findModuleByAddress(parg2).name; var so_path = Process.findModuleByAddress(parg2).path; var so_base = Module.getBaseAddress(so_name); var offset = parg2 - so_base; var PC = 0; if ((so_name.indexOf("libexec.so") > -1)) { console.log("find thread func offset", so_name, offset); } else { PC = pthread_create(parg0, parg1, parg2, parg3); } return PC; }, "int", ["pointer", "pointer", "pointer", "pointer"]))}hook_pthread(); 找到了libexec.so开启pthread_create的偏移量,对其进行bypass,即 function hook_pthread() { var pthread_create_addr = Module.findExportByName(null, 'pthread_create'); var pthread_create = new NativeFunction(pthread_create_addr, "int", ["pointer", "pointer", "pointer", "pointer"]); Interceptor.replace(pthread_create_addr, new NativeCallback(function (parg0, parg1, parg2, parg3) { var so_name = Process.findModuleByAddress(parg2).name; var so_path = Process.findModuleByAddress(parg2).path; var so_base = Module.getBaseAddress(so_name); var offset = parg2 - so_base; var PC = 0; if ((so_name.indexOf("libexec.so") > -1)) { console.log("find thread func offset", so_name, offset); if ((207076 === offset)) { console.log("anti bypass"); } else if (207308 === offset) { console.log("anti bypass"); } else if (283820 === offset) { console.log("anti bypass"); } else if (286488 === offset) { console.log("anti bypass"); } else if (292416 === offset) { console.log("anti bypass"); } else if (78136 === offset) { console.log("anti bypass"); } else if (293768 === offset) { console.log("anti bypass"); } else { PC = pthread_create(parg0, parg1, parg2, parg3); } } else { PC = pthread_create(parg0, parg1, parg2, parg3); } return PC; }, "int", ["pointer", "pointer", "pointer", "pointer"]))}hook_pthread(); 已经对其进行绕过frida的检测。 3、class的遍历和hook 绕过frida的检测之后,开始对其加载的class以及class中的函数进行遍历 Java.enumerateLoadedClasses({ onMatch: function(className) { console.log("found class >> " + className); //遍历类中所有的方法和属性 var jClass = Java.use(className); console.log(JSON.stringify({ _name: className, _methods: Object.getOwnPropertyNames(jClass.__proto__).filter(function(m) { return !m.startsWith('