Hook框架(Firda)

https://www.52pojie.cn/thread-1746855-1-1.html

给虚拟机安装frida服务

#查看cpu架构  记得版本号要一样
getprop ro.product.cpu.abi
  • 解压并push到 /data/local/tmp 目录下

adb push xxx /data/local/tmp/frida-server
  • 切换root并给执行权限

su
chmod 777 frida-server
  • 运行

./frida-server

PC运行frida

#推荐使用应用名 而不是包名
frida -U -l exploit.js -f xxx #启动app并注入脚本
frida-ps -U
frida-ps -Ua
frida -U -l exploit.js "XXXX" #app已经启动 注入脚本

脚本

Java.perform(function() {
    const MainActivity = Java.use('com.example.hotfix.MainActivity');
    MainActivity.getarrly.implementation = function() {
        console.log('getarrly() 方法被调用');
        printStack();
        this.getarrly();
    };
});

//打印调用栈
function printStack() {
    Java.perform(function () {
        var Exception = Java.use("java.lang.Exception");
        var ins = Exception.$new("Exception");
        var straces = ins.getStackTrace();
        if (straces != undefined && straces != null) {
            var strace = straces.toString();
            var replaceStr = strace.replace(/,/g, "\r\n");
            console.log("=============================Stack strat=======================");
            console.log(replaceStr);
            console.log("=============================Stack end=======================\r\n");
            Exception.$dispose();
        }
    });
}

效果