使用 Frida 的 JS API 动态调试安卓应用

前言

不想修改应用代码或没有条件修改应用代码,怎么进行动态调试?

(接上文:使用 frida-dexdump 获取加固 apk 的 dex)

编写调试脚本

console.log("等待 3s 后再插桩...");
// 等待几秒再 hook, 确保动态加载的类已经载入
setTimeout(function () {
    console.log("开始插桩...");
    Java.perform(function () {
        // 获取目标类
        let TargetClass = Java.use("com.example.class");
        // 拦截目标方法
        TargetClass.exampleMethod.implementation = function () {
            console.log("[call] com.example.class.exampleMethod\n" + "[args] " + JSON.stringify(arguments));
            // 调用原始方法
            let returnValue = this.exampleMethod.apply(this, arguments);
            // 在这里你可以处理 returnValue,比如打印它
            console.log("[return]", JSON.stringify(returnValue), "\n");
            // 返回原始方法的返回值
            return returnValue;
        };
    });
}, 3000);

执行脚本

指定包名,执行 hook 脚本

frida -U -l hook.js -f com.example.app

本文链接:

https://blog.nkxingxh.top/archives/385/
1 + 8 =
快来做第一个评论的人吧~