frida的使用

编程入门 行业动态 更新时间:2024-10-24 01:59:07

<a href=https://www.elefans.com/category/jswz/34/1753341.html style=frida的使用"/>

frida的使用

配置环境

github地址: 

安装frida

安装最新版frida

pip install frida-tools

PS: 注意用管理员权限运行cmd

安装指定版本的frida 

1. 首先卸载已经安装的frida

pip uninstall frida

pip uninstall frida-tools

2. 指定版本安装(注意python版本)

#安装frida指定版本(双等号后加版本即可)

pip install frida==16.1.4

然后查看指定版本的frida对应的frida-tools版本,直接github上找到该版本对应即可

#安装对应版本的frida-tools

pip install frida-tools==12.2.1

当前pixel6 安卓13 使用python版本 3.11.5  frida&frida-server 16.1.4  frida-tools 12.2.1 可以正常使用 

验证是否安装成功

>frida --version
16.1.4  //输出版本说明frida-tool安装成功>python
Python 3.10.7 (tags/v3.10.7:6cc6b13, Sep  5 2022, 14:08:36) [MSC v.1933 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import frida  //python可以正常import frida说明frida安装成功
>>>

3. frida server安装

找到和当前frida版本一直的frida-server下载即可: .1.4/frida-server-16.1.4-android-arm64.xz

下载解压后推送到手机,这里推送到 /data/local/tmp目录下,并重命名文件为fs,然后给予fs权限,然后启动frida-server

#推送到手机
adb push frida-server-16.1.4-android-arm64 /data/local/tmp/fs#给予权限
chmod 777 /data/local/tmp/fs#启动frida-server
/data/local/tmp/fs
验证frida-server是否正常启动

vscode中编写一个js文件 test.js ,js文件中加入一行输入即可 console.log("frida server 设置成功!");

然后在terminal中执行下面的代码,注入js文件到当前手机所在的app进程

> frida -UF -l .\test.js____/ _  |   Frida 16.1.4 - A world-class dynamic instrumentation toolkit| (_| |> _  |   Commands:/_/ |_|       help      -> Displays the help system. . . .       object?   -> Display information about 'object'. . . .       exit/quit -> Exit. . . .. . . .   More info at /. . . .. . . .   Connected to Pixel 6 (id=19161FDF600A68)
frida server 设置成功!  //输出这里说明frida-server 正常启动
frida关闭 
1. 关闭cmd窗口关闭frida客户端和服务端

由于是在cmd中通过adb shell启动的fs,最简单的方法是直接关闭cmd,这样frida-server会自动关闭,这也要求使用中不要关闭cmd,不然frida-server就关闭了.

2. 关闭frida-server进程

也可以查找frida-server进程,然后kill -9强制关闭进程.注意如果把frida-server改名了,查找时需要注意

1|oriole:/ $ ps -ef|grep fs|grep -v grep
root           285     2 0 21:19:57 ?     00:00:00 [ufs_mgc_hibern8]
root           286     2 0 21:19:57 ?     00:00:00 [ufs_eh_wq_0]
root           287     2 0 21:19:57 ?     00:00:00 [ufs_clk_gating_]
root           319     2 0 21:19:58 ?     00:00:00 [gpu-dvfs-contro]
root           320     2 0 21:19:58 ?     00:00:00 [gpu-dvfs-clockd]
root           477     1 0 21:19:58 ?     00:00:40 vold --blkid_context=u:r:blkid:s0 --blkid_untrusted_context=u:r:blkid_untrusted:s0 --fsck_context=u:r:fsck:s0 --fsck_untrusted_context=u:r:fsck_untrusted:s0
root           623     2 0 21:19:59 ?     00:03:37 [f2fs_ckpt-254:4]
root           624     2 0 21:19:59 ?     00:00:00 [f2fs_flush-254:]
root           625     2 0 21:19:59 ?     00:00:55 [f2fs_discard-25]
root           643     2 0 21:19:59 ?     00:00:05 [f2fs_gc-254:42]
radio         1014     1 0 21:20:01 ?     00:01:23 rfsd -d
system        1639     1 0 21:20:04 ?     00:00:09 storageproxyd -d /dev/trusty-ipc-dev0 -r /dev/sg1 -p /data/vendor/ss -t ufs
root         14277     2 0 10:17:31 ?     00:00:01 [kworker/u17:0-ufs_clk_gating_0]
root         15842     2 0 10:33:20 ?     00:00:00 [kworker/u17:2-ufs_clk_gating_0]
root         16974 16753 0 10:41:59 136:0 00:00:00 fs
oriole:/ $ kill -9 16974
/system/bin/sh: kill: 16974: Operation not permitted
1|oriole:/ $ su
oriole:/ # kill -9 16974

4. frida 代码提示配置

在vscode的frida项目根目录下执行局部安装即可

npm -i @types/frida-gun

frida的基本用法

frida的代码尽量使用java.perform给包起来

1. hook实例方法

Java.perform(function () {// hook方法let MainActivity = Java.use("com.zj.wuaipojie2023_3.MainActivity");MainActivity["check"].implementation = function () {console.log(`MainActivity.check is called`);let result = this["check"]();console.log(`MainActivity.check result=${result}`);return 999;};// 主动调用实例方法// 首先获得实例Java.choose("com.zj.wuaipojie2023_3.MainActivity",{onMatch:function(obj){console.log("onMatch: ",obj);obj.setNum(998);},onComplete:function(){console.log("choose complete!")}})//主动调用实例方法: 解密函数Java.choose("com.zj.wuaipojie2023_3.MainActivity", {onMatch: function (obj) {let result = obj.decrypt(`hnci}|jwfclkczkppkcpmwckng\u007f`, 2);console.log("解密结果: ", result);},onComplete:function(){}});
});

注意: 调用实例方法时,Java.choose第二个参数对象中的onComplete方法不能省略,可以写成空方法,但是不能省略,否则会报错!

更多推荐

frida的使用

本文发布于:2023-11-16 10:18:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1617705.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:frida

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!