Victo

我的网络笔记本,用于收藏和总结一些知识。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: :: :: 管理 ::

0. Frida官方资料学习

官方网站:https://frida.re/docs/home/

1. 安装firda-server到Android并启动

https://github.com/frida/frida/releases

这里手机是Pixel2(arm64)所以安装:frida-server-12.9.4-android-arm64.xz

 

启动的时候Pixel2(Android 9)有坑是命名行没法启动,提示没有权限(虽然已Root):

Unable to load SELinux policy from the kernel: Failed to open file ?/sys/fs/selinux/policy?: Permission denie

  此时可以采用的启动办法是:

adb shell
$ su
# /data/local/tmp/frida-server &

2. 安装frida-tools

这里在Windows7_X64上安装frida-tools,经历非常的坎坷,要注意安装上述对应版本(12.9.4)的frida-tools要注意以下几点:

(1)使用的frida注意一定要是跟Android上使用的frida-server版本一致。

(2)最新版的frida(12.9.4)要使用Python3.8,注意还不能是3.7这种。。

(3)直接用pip3 install frida-tools不知道为什么就会一直卡在(但是在MacOSX上安装却没有这个问题,很快就能装好,可能是Windows平台特有问题):Running setup.py install for frida ... –

(4)就算更换国内pip源一样的会卡住,这个时候可以手动先把frida安装一下再pip3 install frida-tools,方法如下:

https://pypi.org/project/frida/#files
1)手动下载frida包:
https://files.pythonhosted.org/packages/28/45/47fed8715620ca607e3a3802aab4165714e3fd95c1e8eb35c0c432cf83b0/frida-12.9.4-py2.7-win-amd64.egg
2)放置到本地:
C:\Users\liuheng.klh\AppData\Local\Programs\Python\Python38\Lib\site-packages\frida-12.9.4-py3.8-win-amd64.egg

(3)非常关键的一步,要用easy_install去安装一下egg文件(网友不知道这个方法走了弯路):
C:\Users\liuheng.klh\AppData\Local\Programs\Python\Python38\Scripts>easy_install.exe  C:\Users\liuheng.klh\AppData\Local\Programs\Python\Python38\Lib\site-packages\frida-12.9.4-py3.8-win-amd64.egg

(4)最后用pip3执行就可以了:
pip3 install frida-tools

3. 简单示例

如果担心frida-server工作不正常拿不到进程信息,可以重新启动一下frida-server进程,在客户端可以测试一下效果:

C:\Users\liuheng.klh>frida-ps -U
  PID  Name
-----  ---------------------------------------------------
 6466  ATFWD-daemon
  794  adbd
  819  adsprpcd
  499  android.hardware.atrace@1.0-service
  661  android.hardware.audio@2.0-service
  838  android.hardware.biometrics.fingerprint@2.1-service
  662  android.hardware.bluetooth@1.0-service-qti
  500  android.hardware.boot@1.0-service
  663  android.hardware.camera.provider@2.4-service
。。。 。。。

 抓一下进程的某个方法调用情况,非常轻松就能看到函数的调用时间戳:

C:\Users\liuheng.klh>frida-trace -U -i eglSwapBuffers com.auto***.***auto
Instrumenting functions...
eglSwapBuffers: Loaded handler at "C:\\Users\\liuheng.klh\\__handlers__\\libOpenMAXAL.so\\eglSwapBuffers.js"
eglSwapBuffers: Loaded handler at "C:\\Users\\liuheng.klh\\__handlers__\\libEGL_adreno.so\\eglSwapBuffers.js"
Started tracing 2 functions. Press Ctrl+C to stop.
           /* TID 0x2cb2 */
   297 ms  eglSwapBuffers()
   298 ms     | eglSwapBuffers()
   327 ms  eglSwapBuffers()
   327 ms     | eglSwapBuffers()
   720 ms  eglSwapBuffers()
   720 ms     | eglSwapBuffers()
  1141 ms  eglSwapBuffers()
  1142 ms     | eglSwapBuffers()
  1333 ms  eglSwapBuffers()
  1333 ms     | eglSwapBuffers()
  1560 ms  eglSwapBuffers()
  1561 ms     | eglSwapBuffers()
  1977 ms  eglSwapBuffers()
  1977 ms     | eglSwapBuffers()
  2330 ms  eglSwapBuffers()

4. 查找C++函数Hook目标

Android符号库中是包含所有符号的,用如下nm命令可以拿到:

nm -D libXXX.so | grep *** 

 其实frida-trace可以支持通配符的,不需要填写完整的符号名。

posted on 2020-05-23 23:16  VictoKu  阅读(3444)  评论(0编辑  收藏  举报