iOS应用脱壳

iOS应用脱壳

基于Frida的脱壳方法

主要参考:Link

frida-ios-dump

  • 步骤1: 在手机上安装Frida,分为越狱设备和非越狱设备两种。参见官方文档:Link

  • 步骤2: 在mac上安装Frida

    1
    2
    3
    4
    # Python API binding
    $ pip install frida
    # frida command
    $ pip install frida-tools

    注意:在安装frida-tools时,出现了报错ERROR: No matching distribution found for prompt-toolkit<4.0.0,>=3.0.3 (from frida-tools),单独安装 prompt后pip install prompt后发现没有影响,原因可参考另一项目的issue。其实在requirements.txt文件中也写明了prompt包,因此也不用手动单独安装prompt

  • 步骤三:下载frida-ios-dump脚本,安装依赖

    1
    2
    3
    $ git clone https://github.com/AloneMonkey/frida-ios-dump.git
    $ cd frida-ios-dump
    $ pip install -r requirements.txt --upgrade

    注意:如果设备的连接信息(e.g. ssh默认的连接密码alpine)已经修改,要修改脚本中对应的信息

    1
    2
    3
    4
    5
    6
    7
    $ vim dump.py
    ...
    # 手机连接配置
    User = 'root'
    Password = 'alpine'
    Host = 'localhost' # 此处不用修改
    Port = 2222
  • 通过USB使用SSH连接设备

    参考:Link

    该脚本使用SSH连接进行操作(基于Frida),但使用Wi-Fi的SSH容易不稳定,因此可以使用iproxy工具将SSH的22端口转发到一个本地端口2222,再通过USB连接,会更加稳定。

    1
    2
    # USB连接你的Mac,新开一个命令行窗口,进行转发
    $ iproxy 2222 22
  • 使用脚本

    默认使用USB连接,需要进行端口转发

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    $ ./dump.py -h
    usage: dump.py [-h] [-l] [-o OUTPUT_IPA] [-H SSH_HOST] [-p SSH_PORT]
    [-u SSH_USER] [-P SSH_PASSWORD]
    [target]

    frida-ios-dump (by AloneMonkey v2.0)

    positional arguments:
    target Bundle identifier or display name of the target app

    optional arguments:
    -h, --help show this help message and exit
    -l, --list List the installed apps
    -o OUTPUT_IPA, --output OUTPUT_IPA
    Specify name of the decrypted IPA
    -H SSH_HOST, --host SSH_HOST
    Specify SSH hostname
    -p SSH_PORT, --port SSH_PORT
    Specify SSH port
    -u SSH_USER, --user SSH_USER
    Specify SSH username
    -P SSH_PASSWORD, --password SSH_PASSWORD
    Specify SSH password

故障备忘

第一次执行后报错

unable to attach to the specified process

原来是因为手机没有安装Frida.

Reference

[0] https://www.exchen.net/ios-hacker-frida-ios-dump.html

[1] https://www.jianshu.com/p/79d2d9f3958c

[2] https://www.exchen.net/ios-hacker-frida-ios-dump.html

[3] https://www.jianshu.com/p/4aee1c07d1da

[4] http://blog.okeyang.com/blog/2013/09/16/iproxy-tong-guo-usbshi-yong-sshlian-jie-iosshe-bei/

[5] https://blog.aberlt.com/2017/12/14/%E8%AE%B0%E7%A0%B8%E5%A3%B3%E5%B7%A5%E5%85%B7-frida-ios-dump-%E7%9A%84%E4%BD%BF%E7%94%A8/