frida 的使用
通过frida -h
显示帮助信息
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
-F, --attach-frontmost
attach to frontmost application
-n NAME, --attach-name=NAME
attach to NAME
-p PID, --attach-pid=PID
attach to PID
--stdio=inherit|pipe stdio behavior when spawning (defaults to “inherit”)
--aux=option set aux option when spawning, such as “uid=(int)42”
(supported types are: string, bool, int)
--realm=native|emulated
realm to attach in
--runtime=qjs|v8 script runtime to use
--debug enable the Node.js compatible script debugger
--squelch-crash if enabled, will not dump crash report to console
-O FILE, --options-file=FILE
text file containing additional command line options
-l SCRIPT, --load=SCRIPT
load SCRIPT
-P PARAMETERS_JSON, --parameters=PARAMETERS_JSON
parameters as JSON, same as Gadget
-C CMODULE, --cmodule=CMODULE
load CMODULE
--toolchain=any|internal|external
CModule toolchain to use when compiling from source
code
-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
--eternalize eternalize the script before exit
--exit-on-error exit with code 1 after encountering any exception in
the SCRIPT
常用选项
--version
显示 frida 的版本号并退出。-h,--help
显示帮助信息,列出所有可用选项并退出。-U, --usb
通过 USB 连接到设备。-H HOST, --host=HOST
连接到指定 HOST 上的远程 frida-server。-D ID, --device=ID:
连接到指定 ID 的设备。-f FILE, --file=FILE
spawn模式,启动指定的文件(启动一个新的进程并挂起)。-F, --attach-frontmost
attach模式,附加到前台运行的应用程序。-n NAME, --attach-name=NAME
附加到指定名称的应用程序。-p PID, --attach-pid=PID
附加到指定进程 ID 的应用程序。-l SCRIPT, --load=SCRIPT
加载指定的脚本文件。--no-pause:
启动后自动启动主线程,通常配合-f
选项使用。-o LOGFILE, --output=LOGFILE:
将输出记录到指定的日志文件中。
设备连接
通过USB连接
用一根USB数据线将手机和电脑连接起来,启动frida-server
这里写一段测试代码test.js
function usbTest(){
Java.perform(function (){
console.log("USB connected!")
})
}
setImmediate(function (){
usbTest();
})
通过命令执行frida -UF -l test.js
,可以看到输出结果,那么USB就连接成功了。
通过HOST连接
先通过USB连接把frida-server启动起来,在启动的时候加上-l
选项来设置监听的地址,
ip地址可以通过ip address
或ifconfig
命令来查看,frida-server的默认监听端口为27042
启动frida-server
./frida-server-14.2.18-android-arm64 -l 192.168.xx.xx:27042
执行命令frida -H 192.168.xx.xx:27042 -F -l test.js
,可以看到输出结果,说明我们通过HOST连接成功了
这里有需要注意的是,通过HOST连接需要确保手机和电脑能够互相Ping通,这就需要手机和电脑在相同的网段下,电脑开着防火墙的话手机是Ping不同电脑的。
frida-server的选项
常用的选项
--version
输出版本信息-l
设置监听地址
WiFi ADB
这里有一个好用的adb连接工具,WiFi ADB
软件允许用户通过无线网络(Wi-Fi)连接和控制Android设备,而不需要使用USB线。
官网链接WiFi ADB (需要科学上网)
下载安装到手机端,就可以通过WiFi进行adb调试(需要连接同一个WiFi)。
根据提示进行操作即可
连接成功