软件与参考

1
2
3
brew install jtool
brew install ldid
brew install usbmuxd

Frida https://www.frida.re/
Frida-Github https://github.com/frida/frida/releases
frida-ios-dump https://github.com/AloneMonkey/frida-ios-dump.git
一条命令完成砸壳 http://www.alonemonkey.com/2018/01/30/frida-ios-dump/

Go

先来看一下ipa是否有壳:

1
2
3
4
5
6
7
8
9
10
11
12
file xxx.ipa/Payload/xxx
xxx: Mach-O universal binary with 2 architectures: [arm_v7:Mach-O executable arm_v7] [arm64]
xxx (for architecture armv7): Mach-O executable arm_v7
xxx (for architecture arm64): Mach-O 64-bit executable arm64

otool -l xxx.ipa/Payload/xxx |grep crypt
cryptoff 16384
cryptsize 49299456
cryptid 1
cryptoff 16384
cryptsize 56147968
cryptid 1

如果显示cryptid为1,即为AppStore加壳版本,需要脱壳后才能各种操作。

脱壳需要一台完美越狱的iOS手机,将对应版本的frida-server安装到手机上。如果frida无法运行,一般需要进行签名。
创建ent.xml文件:

1
2
3
4
5
6
7
8
9
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>platform-application</key>
<true/>
<key>com.apple.private.security.container-required</key>
<false/>
</dict>
</plist>

签名运行:

1
2
3
ARCH=arm64 ./jtool --sign --ent ent.xml --inplace frida
scp frida root@192.168.xxx.xxx:/bin
iphone shell: /bin/frida

下载frida-ios-dump进行砸壳

1
2
3
4
5
6
7
git clone https://github.com/AloneMonkey/frida-ios-dump.git
cd frida-ios-dump
sudo pip install -r requirements.txt --upgrade
iproxy 2222 22
./dump.py -l
./dump.py WeChat
./dump.py -b com.tencent.xin

dump出来的ipa将出现在当前目录,如果需要操作其中的Arch版本,可以用以下命令:

1
2
3
4
lipo -create xxx32 xxx64 -output xxxfat
lipo XXXX -thin armv7 -output XXXX_armv7
lipo XXXX -thin arm64 -output XXXX_arm64
lipo -info xxx

完美ipa需要两部iOS手机,一个32位(iPhone 5或以前),一个64位(iPhone 5s或以后),分别导出armv7和arm64,再合并成新的ipa。