1、在Mac上安装Frida
==Mac系统的frida版本要与Android中的版本号保持一致==。
升级Mac系统中的frida为最新版本的命令:
sudo pip install --upgrade frida
或者安装指定版本的frida,这里安装frida的12.1.2版本:
pip install frida==12.1.2
2、为Android手机安装Frida
我的root设备是Android4.4.4系统
下载frida-server到电脑中,地址:frida-server
选择合适的版本,我这里下载的是frida-server-12.1.2-android-arm.xz
下载到电脑要解压这个.xz文件,Mac系统如果不能识别这个文件,可到App Store安装一个叫"The Unarchiver"的工具。
解压后修改文件名为"frida-server",并复制文件到手机对应的目录下:
adb push frida-server /data/local/tmp/
继续在终端输入命令,为frida-server添加执行权限,并启动手机中的frida-server:
$ adb shell
shell@hammerhead:/ $ su
root@hammerhead:/ # cd /data/local/tmp/
root@hammerhead:/data/local/tmp # chmod 777 frida-server
root@hammerhead:/data/local/tmp # ./frida-server &
手机会重启,重启之后,mac新开一个终端输入命令检查手机上的frida是否运行成功:
frida-ps -U
成功则会打印手机中运行的进程:
PID Name
----- ----------------------------------------------
25851 adb
25767 adbd
31402 android.process.acore
31675 android.process.media
187 bridgemgrd
32228 com.android.defcontainer
...
...
3、可能会遇到的错误
错误1
$ frida -U --no-pause -f com.android.chrome
____
/ _ | Frida 12.1.2 - A world-class dynamic instrumentation toolkit
| (_| |
> _ | Commands:
/_/ |_| help -> Displays the help system
. . . . object? -> Display information about 'object'
. . . . exit/quit -> Exit
. . . .
. . . . More info at http://www.frida.re/docs/home/
Failed to spawn: the connection is closed
错误2
$frida-ps -Ua
Failed to enumerate applications: the connection is closed
我遇到的错误1和错误2,都是因为手机的Frida版本和Mac电脑的Frida版本不同导致的,安装相同版本的Frida就可解决。
使用frida强制启动chrome报错
$ frida -U --no-pause -f com.android.chrome
Traceback (most recent call last):
File "/Users/king/Documents/PythonProject/Tornado/test/venv/bin/frida", line 11, in <module>
sys.exit(main())
File "/Users/king/Documents/PythonProject/Tornado/test/venv/lib/python2.7/site-packages/frida_tools/repl.py", line 23, in main
from prompt_toolkit.shortcuts import create_prompt_application, create_output, create_eventloop
ImportError: cannot import name create_prompt_application
解决:
pip install 'prompt-toolkit==1.0.15'