2024 最新 frida技术栈 第一部分
目录
1.下载
2. 安装
2.1. 命令
3.基本使用
3.1 列出运行的APP
3.2 列出所有APP
3.3 杀死进程
4. frida hook 方法
4.1 frida客户端命令行的参数
4.2. Frida两种操作模式
4.3. Frida操作APP的两种方式
4.3.1. attach模式
4.3.2. spawn模式
4.3.3 转发端口启动
1.下载
查看手机设备设置
adb shell getprop ro.product.cpu.abi
显示:
如果安卓版本比较低的话,最新版
frida
不是很稳定。推荐安卓7、8安装frida 12.8.0
版本,安卓10/frida14
,安卓12/frida16
。
官网地址:Releases · frida/frida · GitHub 查看版本一致的进行下载 ,可以重命名成 f14-server
注意:server与client版本必须保持一致
模拟器使用x86或x86_64
架构
真机使用arm或arm64
架构
2. 安装
解压文件,进行推送到模拟器中/data/local/tmp下
2.1. 命令
推送运行命令:adb push fserver /data/local/tmp/
现在执行:adb shell
切换管理员:su
进入目录:cd /data/local/tmp
改下权限:chmod 777 /f14-server
然后就可以运行了:./f14-server
2.2. 端口转发
adb forward tcp:27042 tcp:27042
2.3 运行
./frida-server -l 0.0.0.0:6666
3.基本使用
3.1 列出运行的APP
frida-ps -Ua
3.2 列出所有APP
frida-ps -Uai
3.3 杀死进程
frida-kill -U 包名
4. frida hook 方法
4.1 frida客户端命令行的参数
Usage: frida [options] target
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-D ID, --device=ID connect to device with the given ID
-U, --usb connect to USB device
-R, --remote connect to remote frida-server
-H HOST, --host=HOST connect to remote frida-server on HOST
-f FILE, --file=FILE spawn FILE
-n NAME, --attach-name=NAME
attach to NAME
-p PID, --attach-pid=PID
attach to PID
--debug enable the Node.js compatible script debugger
--enable-jit enable JIT
-l SCRIPT, --load=SCRIPT
load SCRIPT
-c CODESHARE_URI, --codeshare=CODESHARE_URI
load CODESHARE_URI
-e CODE, --eval=CODE evaluate CODE
-q quiet mode (no prompt) and quit after -l and -e
--no-pause automatically start main thread after startup
-o LOGFILE, --output=LOGFILE
output to log file
4.2. Frida两种操作模式
操作模式 | 说明 |
---|---|
CLI命令行 | Javascript脚本注入进程 |
RPC | Python进行Javascript脚本注入 |
4.3. Frida操作APP的两种方式
方式名称 | 方式说明 | CLI下启动方式 |
---|---|---|
spwan | 将启动APP的权利交由Frida来控制。不管APP是否启动,都会重新启动APP。 | -f参数指定包名 |
attach | 建立在目标APP已经启动的情况下,Frida通过ptrace注入程序从而执行Hook的操作 | 不加-f参数 |
4.3.1. attach
模式
将一个脚本注入到Android
目标进程,即需要App处于启动状态, 核心原理是ptrace修改进程内存
frida -U -l myhook.js com.xxx.xxxx
参数解释:
-
-U 指定对USB设备操作
-
-l 指定加载一个Javascript脚本
-
最后指定一个进程名,如果想指定进程pid,用
-p
选项。正在运行的进程可以用frida-ps -U
命令查看
4.3.2. spawn
模式
启动一个新的进程并挂起,在启动的同时注入frida代码,注入完成后调用resume恢复进程。
frida -U -l myhook.js -f com.xxx.xxxx --no-pause
参数解释:
-
-f 指定一个进程,重启它并注入脚本
-
--no-pause 自动运行程序
4.3.3 转发端口启动
启动服务端
./frida-server -l 0.0.0.0:8881
端口转发
adb forward tcp:8881 tcp:8881
然后直接cmd
使用该DroidSSLUnpinning.js
文件
frida -H 127.0.0.1:8881 -f com.package.name -l DroidSSLUnpinning.js