文章

IOS逆向安全(1)-环境搭建和IOS越狱

0x01 安装虚拟机

本来一开始打算直接虚拟机安装苹果系统来调试代码,但是装完苹果系统后,虚拟机配置已经拉满还是不流畅,图形卡最多也就125M,直接放弃。于是掏出了17年的Macbook Pro。

0x02 开发环境

MonkeyDev是ios逆向开发的成套工具,下载安装

theos&MonkeyDev

sudo git clone --recursive https://github.com/theos/theos.git /opt/theos
sudo git clone https://github.com/AloneMonkey/MonkeyDev.git /opt/MonkeyDev
cd /opt/MonkeyDev/bin
sudo bash md-install 

安装完后,Xcode创建项目时,就多了下面的选项

0x03 创建tweak

╭─ ~/Desktop ──────────────────────────────────────────────────────────────── ✔ ─╮
╰─ nic.pl                                                                           ─╯
NIC 2.0 - New Instance Creator
------------------------------
  [1.] iphone/application_modern
  [2.] iphone/application_swift_modern
  [3.] iphone/application_swiftui
  [4.] iphone/control_center_module-11up
  [5.] iphone/framework
  [6.] iphone/library
  [7.] iphone/null
  [8.] iphone/preference_bundle
  [9.] iphone/preference_bundle_swift
  [10.] iphone/theme
  [11.] iphone/tool
  [12.] iphone/tool_swift
  [13.] iphone/tweak
  [14.] iphone/tweak_swift
  [15.] iphone/tweak_with_simple_preferences
  [16.] iphone/xpc_service_modern
Choose a Template (required): 13
Project Name (required): wechat
Package Name [com.yourcompany.wechat]: cn.txf7.wechat
Author/Maintainer Name [txf]: txf
[iphone/tweak] MobileSubstrate Bundle filter [com.apple.springboard]: com.tencent.xin
[iphone/tweak] List of applications to terminate upon installation (space-separated, '-' for none) [SpringBoard]: WeChat
Instantiating iphone/tweak in wechat/...
Done.

0x04 查看本地苹果证书

### 判断APP是否加密
otool -l /Users/txf/Desktop/Payload/WeChat.app/WeChat  | grep -B 2 crypt
### 查看本地证书
security find-identity -v -p codesigning

### Framework重签名
codesign -fs "Apple Development: 415973395@qq.com (76F3D69Q8J)" App.framework
codesign -fs "Apple Development: 415973395@qq.com (76F3D69QJ)" 。。。.framework
codesign -fs "Apple Development: 415973395@qq.com (76F3D69Q8J)" 。。。.framework

0x05 越狱

手上的是苹果12,系统14.5,使用Taurine来越狱

然后开始安装frida,苹果12使用的是下面版本

python3.8.6

frida==15.2.2

frida-tools==11.0.0

objection==1.11.0

下载地址:

https://pypi.org/simple/frida/

https://github.com/frida/frida/releases?page=7

scp  -P 2222 frida_15.2.2_iphoneos-arm.deb root@127.0.0.1:/tmp

在苹果手机里安装,安装后自动运行

dpkg -i frida_15.2.2_iphoneos-arm.deb
ps aux |grep frida

本地执行查看手机程序

frida-ps -U

但是用了一会手机闪退了,最后发现还是因为手机系统的原因。

只能换越狱方,使用Fugu14支持的iOS 14.3 - 14.5.1越狱,同时目前只能通过编译Fugu14项目源码然后在苹果电脑本地进行调用unc0ver越狱,最终成功越狱,比较稳定。

0x05 越狱x2 多巴胺越狱

新购了一台二手14promax,版本是16.1.1的,直接使用多巴胺越狱,流程是:

安装巨魔->巨魔安装多巴胺->一键越狱

同时 arm需要换成 arm64

使用下面的版本

python3.13.2

frida==16.7.0

frida-tools==13.6.1

objection==1.11.0

brew install pyenv

#环境变量
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
source ~/.zshrc

#安装3.13.2
pyenv install 3.13.2

#全局
pyenv global 3.13.2
#当前目录
pyenv local 3.13.2
#临时
pyenv shell 3.13.2

#清除临时目录的设置
pyenv local --unset

frida_16.7.0_iphoneos-arm64.deb

pip install frida
pip install frida-tools

pyenv which python
#/Users/txf/.pyenv/versions/3.13.2/bin/python
export PATH="/Users/txf/.pyenv/versions/3.13.2/bin:$PATH"

scp frida_16.7.0_iphoneos-arm64.deb root@192.168.1.65:/tmp
dpkg -i frida_16.7.0_iphoneos-arm64.deb
ps aux |grep frida