PS: 后面寫有一篇砸殼成 ipa 的,但是這篇也得看。要不然有些基礎(chǔ)你不知道。
特別聲明此文只是對(duì)以下博客的總結(jié)筆記:(這位博主寫的很詳細(xì)大家可以去他的博客看看)
參考博主: http://www.itdecent.cn/p/4da57be23275
原理:通過(guò)越獄手機(jī)將砸殼文件注入到要砸殼 app 的沙盒目錄下面,然后執(zhí)行砸殼程序。
開(kāi)始之前準(zhǔn)備要的工具:
1. 一臺(tái)越獄的手機(jī)(在越獄機(jī)上Cydia上安裝 openSSH 和 Cycript)[這里我用的是:iPhone 5c iOS 8.3]
oppenSSH: 這個(gè)是通過(guò) Mac 終端連接越獄手機(jī)的文件
Cycript:這個(gè)能找到要砸殼 app 的沙盒文件路徑(還有其他強(qiáng)大的用法可去Google)
2. dumpdecrypted 代碼 ----這個(gè)是要注入app 的砸殼文件
3. class-dump 代碼 ----這個(gè)是 Mac 終端對(duì)砸殼之后的 app 導(dǎo)出頭文件使用的文件
步驟:四步
一、先把 dumpdecrypted 編譯成動(dòng)態(tài)庫(kù), 很簡(jiǎn)單:終端切換到下載到的文件夾下,make 回車就好了。
二、把砸殼文件復(fù)制到要砸殼 app 的沙盒路徑
注意??:(手機(jī)和電腦需要在同一網(wǎng)段,其實(shí)手機(jī)和 Mac 通過(guò) USB 連接最好,或者通過(guò)網(wǎng)絡(luò)共享也是可以的)
要輸入密碼的默認(rèn)是:alpine (請(qǐng)記住這個(gè)密碼,下面很多地方用到)
2.1 終端連接手機(jī): ssh root@手機(jī)IP
例如:
Mac$ ssh root@192.168.8.12
root@192.168.8.12's password:
iPhone4:~ root# (此時(shí)表示連接手機(jī)成功)
2.2 找到要砸殼 app 的沙盒路徑
手機(jī)上運(yùn)行要砸殼的 app ,和殺掉所有不相關(guān) app, 為了方便找到該 app
Mac 終端輸入:ps -e
例如:
iPhone4:~ root# ps -e
PID TTY TIME CMD
1556 ?? 0:00.10 /usr/libexec/afc2d -S -L -d /
1564 ?? 0:03.07 /usr/libexec/deleted --idleExit
1566 ?? 0:00.15 /System/Library/PrivateFrameworks/GeoServices.framework/geod
1568 ?? 0:00.36 /usr/libexec/mobileassetd
1570 ?? 0:00.63 /System/Library/Frameworks/AssetsLibrary.framework/Support/assetsd
1612 ?? 0:00.37 sshd: root@ttys000
1622 ?? 0:06.20 /var/mobile/Applications/B1215D4A-24B7-480F-B91D-8F5386B0211A/xxx.app/xxx
1623 ?? 0:00.10 /System/Library/Frameworks/UIKit.framework/Support/pasteboardd
1613 ttys000 0:00.05 -sh
1628 ttys000 0:00.01 ps -e
iPhone4:~ root#
注意??:/var/mobile/ 開(kāi)頭的就是我們手機(jī)運(yùn)行的 app 路徑
2.3 使用Cycript 找到 app 的 Documents 目錄路徑,它很強(qiáng)大可進(jìn)行很多牛逼的操作
?? # xxx : 這是該 app 的名(不帶.app)
iPhone4:~ root# cycript -p xxx
cy# [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask][0]
#"file:///var/mobile/Applications/B1215D4A-24B7-480F-B91D-8F5386B0211A/Documents/"
cy#[control+D,來(lái)退出Cycript]
2.4 步驟二,最后一步,把砸殼文件復(fù)制到剛才得到的路徑下面
Mac$ scp /Users/Mac/Desktop/dump/dumpdecrypted.dylib root@192.168.8.12:/var/mobile/Applications/B1215D4A-24B7-480F-B91D-8F5386B0211A/Documents/
root@192.168.8.12's password:
dumpdecrypted.dylib 100% 81KB 81.0KB/s 00:00
Mac$
三、執(zhí)行砸殼文件
iPhone4:~ root# cd /var/mobile/Applications/B1215D4A-24B7-480F-B91D-8F5386B0211A/Documents/
iPhone4:/var/mobile/Applications/B1215D4A-24B7-480F-B91D-8F5386B0211A/Documents root# DYLD_INSERT_LIBRARIES=dumpdecrypted_7.dylib /var/mobile/Applications/B1215D4A-24B7-480F-B91D-8F5386B0211A/xxx.app/xxx
mach-o decryption dumper
DISCLAIMER: This tool is only meant for security research purposes, not for application crackers.
[+] detected 32bit ARM binary in memory.
[+] offset to cryptid found: @0x4a4c(from 0x4000) = a4c
[+] Found encrypted data at address 00004000 of length 46284800 bytes - type 1.
[+] Opening /private/var/mobile/Applications/B1215D4A-24B7-480F-B91D-8F5386B0211A/QQ.app/QQ for reading.
[+] Reading header
[+] Detecting header type
[+] Executable is a FAT image - searching for right architecture
[+] Correct arch is at offset 16384 in the file
[+] Opening QQ.decrypted for writing.
[+] Copying the not encrypted start of the file
[+] Dumping the decrypted data into the file
[+] Copying the not encrypted remainder of the file
[+] Setting the LC_ENCRYPTION_INFO->cryptid to 0 at offset 4a4c
[+] Closing original file
[+] Closing dump file
然后接著執(zhí)行:ls
發(fā)現(xiàn)該目錄下有一個(gè) xxx.decrypted 的文件,就是砸殼之后的文件,把它拷貝到 Mac 端
在 Mac 終端(非手機(jī)終端):
Mac$ scp root@192.168.8.12:/var/mobile/Applications/B1215D4A-24B7-480F-B91D-8F5386B0211A/Documents/xxx.decrypted (Mac路徑)
root@192.168.8.12's password:
四、使用class-dump將文件解析
Mac$ cd /Users/damon/Desktop/test
Mac:test Mac$ class-dump --arch armv7 xxx.decrypted > 123.m
Mac:test Mac$
得到的123.m文件就是我們需要的頭文件
其他型號(hào)使用相對(duì)應(yīng)的 4(armv7),4s(armv7),5(armv7),5s(arm64),6(arm64),6s(arm64)
注意??:如果是非 App store 渠道下的包,可以使用該命令:
class-dump -H 越獄包路徑 -o 輸出路徑
例如:
class-dump - H xxx.app -o /user/Desktop/Test