逆向教程 绕过frida反调试

背景说明

部分应用会通过检测 Frida 的特征(如特定字符串、端口、进程名等)进行反调试。常见的绕过方法包括 Hook strcmp 等字符串比较函数,但实现较为繁琐。本文采用 魔改 Frida 的方式,彻底移除其特征字符串,实现高效绕过。

使用魔改 Frida:Rusda

项目地址:taisuii/rusda - Release v16.2.1

  • 该版本完全抹除了 Frida 的字符串特征。
  • 仓库提供详细编译教程,也提供了预编译好的二进制文件。

一、手机端配置

1. 确定设备 CPU 架构

adb shell getprop ro.product.cpu.abi

输出示例:

arm64-v8a

说明:红米 K40 为 arm64 架构,应选择 rusda-server-android-arm64

2. 推送并启动魔改服务端

# 推送文件
adb push rusda-server-android-arm64 /data/local/tmp/

# 进入 shell 并提权
adb shell
su

# 赋予执行权限
chmod +x /data/local/tmp/rusda-server-android-arm64

# 启动服务(自定义端口 54321,监听所有 IP,后台运行)
./rusda-server-android-arm64 -l 0.0.0.0:54321 -D

3. 验证进程 & 管理

# 查看进程
ps -A | grep rusda

# 示例输出
root 5469 1 2237164 50516 do_sys_poll 0 S rusda-server-android-arm64

# 如需终止
kill -9 5469

✅ 至此,手机端配置完成。


二、PC 端环境配置(Windows)

1. 卸载旧版本(避免冲突)

pip uninstall frida frida-tools

建议:也可使用虚拟环境隔离,避免影响其他项目。

2. 安装匹配版本

pip install frida==16.2.1
pip install frida-tools==12.3.0

3. 验证安装

frida --version

预期输出:

16.2.1

三、连接设备并执行 Hook 脚本

1. 连接远程 Frida 服务

frida -H 192.168.0.101:54321 -f com.example.package -l anti_frida.js

参数说明:

  • -H:指定远程主机 IP 和端口(无线调试)
  • -U:若使用 USB 调试则替换为 -U
  • -f:目标应用包名
  • -l:加载绕过脚本

💡 成功连接后,即可绕过反调试,笑容回归!


四、绕过脚本 anti_frida.js

function hook_dlopen() {
    const android_dlopen_ext = Module.findExportByName(null, "android_dlopen_ext");
    if (android_dlopen_ext) {
        Interceptor.attach(android_dlopen_ext, {
            onEnter: function(args) {
                const pathptr = args[0];
                if (pathptr !== null && pathptr !== undefined) {
                    const path = ptr(pathptr).readCString();
                    if (path && path.includes("libmsaoaidsec.so")) {
                        console.log(`android_dlopen_ext >>> load ${path}`);
                        hook_call_constructors_libmsaoaidsec();
                    }
                }
            },
            onLeave: function() {}
        });
    }
}

function hook_call_constructors_libmsaoaidsec() {
    let linker = Process.findModuleByName(Process.pointerSize === 4 ? "linker" : "linker64");
    let call_constructors_addr, get_soname;

    const symbols = linker.enumerateSymbols();
    for (const symbol of symbols) {
        if (symbol.name === "__dl__ZN6soinfo17call_constructorsEv") {
            call_constructors_addr = symbol.address;
        } else if (symbol.name === "__dl__ZNK6soinfo10get_sonameEv") {
            get_soname = new NativeFunction(symbol.address, "pointer", ["pointer"]);
        }
    }

    const listener = Interceptor.attach(call_constructors_addr, {
        onEnter: function(args) {
            const module = Process.findModuleByName("libmsaoaidsec.so");
            if (module) {
                // 替换关键函数入口,实现绕过
                Interceptor.replace(module.base.add(0x1c544), new NativeCallback(() => {
                    console.log("0x1c544: 替换成功");
                }, "void", []));

                Interceptor.replace(module.base.add(0x1b8d4), new NativeCallback(() => {
                    console.log("0x1b8d4: 替换成功");
                }, "void", []));

                Interceptor.replace(module.base.add(0x26e5c), new NativeCallback(() => {
                    console.log("0x26e5c: 替换成功");
                }, "void", []));

                listener.detach(); // 仅执行一次
            }
        },
        onLeave: function(retval) {}
    });
}

// 启动 Hook
hook_dlopen();

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值