1. 下载安装frida工具

Frida工具下载地址:https://github.com/frida/frida/releases

选择对应操作系统版本的Frida工具进行下载安装,这里以Windows系统为例。

  1. 下载安装安卓模拟器

安卓模拟器下载地址:https://www.genymotion.com/download/

根据自己的需求选择适合的版本进行下载安装,这里以Genymotion为例。

  1. 启动安卓模拟器

在Genymotion中选择需要启动的安卓虚拟机,点击“Start”按钮启动虚拟机。

  1. 安装Frida Server

在安卓模拟器中打开终端,执行以下命令安装Frida Server:

adb push frida-server /data/local/tmp/
adb shell chmod 755 /data/local/tmp/frida-server
adb shell /data/local/tmp/frida-server &
  1. 安装应用程序

在安卓模拟器中安装需要进行hook的应用程序,这里以微信为例。

  1. 使用frida-cli进行hook

在电脑端打开命令行工具,进入frida安装目录下的bin目录。

在命令行中执行以下命令连接到安卓模拟器:

frida-ps -U

这里的-U参数表示连接到USB设备,如果需要连接到网络设备,则需要使用-L参数。

执行成功后,会显示当前连接的设备列表,确认连接成功后,继续执行以下命令:

frida -U -l hook.js com.tencent.mm

这里的hook.js表示需要执行的hook脚本,com.tencent.mm表示需要hook的应用程序包名。

hook.js示例代码:

Java.perform(function() {
    var MainActivity = Java.use('com.tencent.mm.ui.LauncherUI');
    MainActivity.onResume.implementation = function() {
        console.log('onResume');
        this.onResume();
    };
});
  1. 查看hook结果

在安卓模拟器中打开微信应用程序,可以看到hook脚本中的日志输出:

[Google Pixel - 8.1.0 - API 27][com.tencent.mm] onResume

至此,使用frida-cli实现安装动态插桩hook的完整示例完成。


原文地址: https://www.cveoy.top/t/topic/Dwo 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录