==Mac系統的frida版本要與Android中的版本號保持一致==。python
升級Mac系統中的frida爲最新版本的命令:android
sudo pip install --upgrade frida
複製代碼
或者安裝指定版本的frida,這裏安裝frida的12.1.2版本:git
pip install frida==12.1.2
複製代碼
個人root設備是Android4.4.4系統github
下載frida-server到電腦中,地址:github.com/frida/frida…chrome
選擇合適的版本,我這裏下載的是frida-server-12.1.2-android-arm.xzshell
下載到電腦要解壓這個.xz文件,Mac系統若是不能識別這個文件,可到App Store安裝一個叫"The Unarchiver"的工具。bash
解壓後修改文件名爲"frida-server",並複製文件到手機對應的目錄下:app
adb push frida-server /data/local/tmp/
複製代碼
繼續在終端輸入命令,爲frida-server添加執行權限,並啓動手機中的frida-server:python2.7
$ 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
...
...
複製代碼
錯誤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'
複製代碼