初步使用frida hook的python和Js代碼
https://frida.re/docs/examples/android/
frida hook與xposed類似,都是用於hook安卓系統對應的進程。
配置需要Hook的機器
建議使用模擬器 https://www.yeshen.com/ ,安裝夜神模擬器中的android 7。低版本安卓系統會導致有些應用運行不了。
不建議root手機開始,root手機流程複雜會耽誤很多時間,在後續hook能力提高很多後再使用真正的硬件設備。
安裝frida
配置python,使用3.x以上的python,如果你使用2.x的,那麼在環境變量中path替換成3.x即可;替換內容就是python安裝地址。
pip安裝frida
pip3 install frida
即可,這個過程會非常慢(下載慢和安裝慢)。解決下載慢,需要將pip下載鏡像換成國內清華源鏡像
在C:\Users\xxxx\目錄下新建pip 文件夾,然後在pip文件內新建 pip.ini 文件,文件內容填入
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
這個過程執行完成後,進行 pip3 install frida
速度會提高很多。注意:這個過程可能出現錯誤,根據它提示的錯誤下載對應的依賴。
pip安裝frida-tools
pip install frida-tools
查看手機型號,下載系統對應版本的 frida-server
adb shell getprop ro.product.cpu.abi
可能你的連接設備有很多,需要執行adb devices,然後根據設備號執行如下命令
adb -s 設備號 shell getprop ro.product.cpu.abi
知道手機型號後 https://github.com/frida/frida/releases 下載frida-server;注意不要選擇錯了。下載完成後需要解壓,解壓後是個可執行文件,需要把它推送到安卓機器上去。
推送到安卓機上
adb push frida-server-12.2.27-android-arm64 /data/local/tmp/frida-server
,推送到手機上同理需要選擇設備號 adb -s 設備號 xxxxx
進入安卓設備執行剛剛推送上去的可執行文件
,執行完畢後爲運行狀態。
adb shell
su
cd /data/local/tmp
chmod 755 frida-server
./frida-server
保留此窗口 shell,以保證服務運行,關閉該shell 或者停止ctrl+c 則服務關閉。接下來的操作可另起shell 或該步驟命令另起 shell 執行。
執行如下命令,驗證frida是否安裝成功
$> frida-ps -U
PID Name
----- ----------------------------------------
4275 com.android.keyguard
4629 com.android.phone
5182 com.android.contacts:cacheservice
...
執行frida -U -f com.xxx.xxx 進行連接,選擇一個進程,等待一段時間則進入該應用
使用現在的例子
初步使用frida hook的python和Js代碼
https://frida.re/docs/examples/android/