• 1. Android逆向-Frida环境搭建



    Frida时当下比较流程的逆向工具,其本身是开源的。在Github上可以找到项目 frida/frida: Clone this repo to build Frida (github.com)。 其官方是地址: Frida • A world-class dynamic instrumentation framework | Inject JavaScript to explore native apps on Windows, macOS, GNU/Linux, iOS, Android, and QNX

    抱着对Android逆向的好奇,来对这个Frida工具做些了解且学习。

    使用的OS是 Ubuntu 20.04,软件工具:JDK 13,Android Studio,python3等。

    Frida环境搭建

    Frida环境分为PC上的安装和设备上的安装。

    PC上安装Frida

    Frida安装Ubuntu下比较简单,再命令行中使用 pip 安装。

    $ pip insall frida-tools
    
    • 1

    下来就是等待安装的完成。

    使用的 pip 工具版本是 21.0.1,产生了错误。

    Running setup.py install for frida ... error
        ERROR: Command errored out with exit status 1:
         // ...
        error: The read operation timed out
        ----------------------------------------
    ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-jsmscq3c/frida_c651e0a74bb748ada5400274e8483634/setup.py'"'"'; __file__='"'"'/tmp/pip-install-jsmscq3c/frida_c651e0a74bb748ada5400274e8483634/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-xs92o31j/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/xacsz/.local/include/python3.8/frida Check the logs for full command output.
    WARNING: You are using pip version 21.0.1; however, version 22.1.2 is available.
    You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    1. pip 版本warning.

      WARNING: You are using pip version 21.0.1; however, version 22.1.2 is available.
      You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
      
      • 1
      • 2

    ​ 根据提示更新pip版本

    $ /usr/bin/python3 -m pip install --upgrade pip 
    
    • 1

    ​ 更新后,在尝试安装Frida,就成功了。(没想到工具对python版本要求这么严格)

    安装完成之后可以通过 frida --version 查看工具版本。

    $ frida --version
    15.1.24
    
    • 1
    • 2

    测试设备的Frida

    要使用Frida测试,除了在PC上安装Frida,还需要在测试机上安装server端Frida。从github上下载:Releases · frida/frida (github.com)

    在此之前需要找到与测试机(这里是Android)的CPU架构匹配的版本。

    通过使用指令**getprop ro.product.cpu.abi**获取设备CPU架构信息。例:Android机设备时 armeabi-v7a,需要下载arm版本。

    $ adb shell
    $ getprop ro.product.cpu.abi
    armeabi-v7a
    
    • 1
    • 2
    • 3

    这样就可以知道CPU采用的是ARM架构,32位。若还想知道更多CPU信息,可以使用查看 /proc/cpuinfo 文件内的内容,包含CPU核心数等。

    $ adb shell
    $ cat /proc/cpuinfo
    
    • 1
    • 2

    查看CPU是几位地址。我这里测试机显示信息是32位。

    processor	: 0
    model name	: ARMv7 Processor rev 5 (v7l)
    BogoMIPS	: 38.40
    Features	: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm 
    CPU implementer	: 0x41
    CPU architecture: 7
    CPU variant	: 0x0
    CPU part	: 0xc07
    CPU revision	: 5
    
    // ...
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    从上述结果看到的是32位架构,因此需要下载的版本是 frida-server-15.1.24-android-arm.xz,这个版本需要PC上安装的版本号一致。

    将xz文件减压缩后,push到设备到 /data/local/tmp目录,并修改权限。

    $ 7z x frida-server-15.1.24-android-arm.xz  # PC机减压缩
    $ adb shell
    $ adb push [path_to_frida] /data/local/tmp/ # 将frida文件push到设备
    $ chmod 777 frida-server-15.1.24-android-arm  # 修改文件权限
    
    • 1
    • 2
    • 3
    • 4

    PC端,测试机端的Frida都安装完成之后,就可以开始使用了。(版本是 15.1.24)

    Python环境

    另外需要补充说的是,Frida使用了Python,javascript等语言,因此需要在PC上安装Python环境。

  • 相关阅读:
    目标检测YOLO实战应用案例100讲-基于改进YOLO的车位导引
    Javaweb之Vue的概述
    python的全局变量和局部变量
    linux早期内存管理:memblock完全介绍
    【蓝桥杯选拔赛真题43】Scratch航天飞行 少儿编程scratch蓝桥杯选拔赛真题讲解
    2022年NPDP考完多久出成绩?怎么查询?
    工程管理系统源码+项目说明+功能描述+前后端分离 + 二次开发
    音视频学习 - 创建QT + ffmpeg项目进行视频解析
    【Python】正则表达式判断是否存在连续N个字母
    Flink standalone 模式下运行WordCount程序过程
  • 原文地址:https://blog.csdn.net/snowgeneral/article/details/126571334