iOS逆向工程:OSX工具集的安裝配置(二)

iOS逆向工程:OSX工具集的安裝配置(一)中是關于class-dump和Theos的安裝配置,這篇文章介紹 Reveal, IDA, dyld_decache的安裝配置.

一.Reveal

Reveal: 由 ITTY BITTY 出品的UI分析工具,可以直觀地查看App的UI布局.
破解地址
下載安裝完成之后,還需要在終端輸入,再打開軟件即可

$ sudo spctl --master-disable

要查看別人App的布局,還需要做以下配置:
1.安裝RevealLoader
在Cydia中搜索并安裝RevealLoader,然后查看iOS上的"/Library/"目錄下有沒有一個名為"RHRevealLoader"的文件夾,如果沒有,則需要手動創(chuàng)建.

root# mkdir /Library/RHRevealLoader

2.使用Cydia安裝兩個軟件:OpenSSHCydiaSubstrate
(1)SSH是一種可以保證用戶加密遠程登錄到系統(tǒng)的協(xié)議,OpenSSH是一個通過SSH接入iOS的連接傳輸工具。
如果在安裝OpenSSH后沒有修改密碼,則默認密碼為alphine,為了降低信息泄露的風險還是重設密碼保險.

查看IP地址的途徑,如下圖第一個就是IP地址

查看IP地址

iOS上的用戶有2個,分別是root和mobile,修改密碼命令如下:

ssh root@iOS設備IP地址
root# passwd root
Changing password for root.
New password:
Retype new password:
root# passwd mobile
Changing password for mobile.
New password:
Retype new password:

(2)CydiaSubstrate是大部分tweak正常工作的基礎,只有安裝了CydiaSubstrate之后才會有MobileSubstrate目錄(此目錄必須存在才可以繼續(xù)下面的步驟)。
MobileSubstrate是一個公共庫,可以用來動態(tài)替換內(nèi)存中的代碼、數(shù)據(jù)等?;旧显姜z機下比較有用的系統(tǒng)工具都需要這個庫,是Cydia同一個作者維護的,可以放心裝。
3.打開mac上的Reveal,在標題欄"Help"選項下,選擇"Show Reveal Library in Finder"子選項.然后把libReveal.dylib通過scp或者iFunBox等方式拷貝到剛才創(chuàng)建的RHRevealLoader目錄下.

使用scp命令的步驟如下:
ssh root@iOS設備IP地址(回車輸入yes,然后輸入密碼)
cd /Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries
scp libReveal.dylib root@iOS設備IP地址:/Library/MobileSubstrate/DynamicLibraries/

4.將Mac上創(chuàng)建libReveal.plist文件,通過iFunBox拷貝到Library/MobileSubstrate/DynamicLibraries中。格式如下:

libReveal.plist

5.保證設備和Mac在同一局域網(wǎng)(Wi-Fi)內(nèi),也就是都選擇同一個Wi-Fi,不必設置http代理,如果App已經(jīng)運行,需在后臺殺死進程重新打開,保持App在前臺運行,然后在Mac中打開Reveal即可.

二.Hopper

破解地址
按照操作步驟進行破解

三.dyld_decache

dyld_decache:提取iOS系統(tǒng)內(nèi)的二進制文件
從iOS 3.1開始,包括frameworks在內(nèi)的許多庫文件被放入了位于/System/Library/Caches/com.apple.dyld/dyld_shared_cache_armx(dyld_shared_cache_armv7,dyld_shared_cache_armv7s,dyld_shared_cache_arm64),可使用dyld_decache將其中的二進制文件提取出來.

1.用iFunBox(不能用scp)從iOS中拷貝dyld_deache到OSX中,查找路徑如下:

System/Library/Caches/com.apple.dyld/dyld_shared_cache_armx

2.下載提取工具dyld_decache

https://github.com/downloads/kennytm/Miscellaneous/dyld_decache[v0.1c].bz2

解壓之后可將dyld_decache[v0.1c] 重命名為dyld_decache

3.賦予其執(zhí)行權限

chmod +x dyld_decache(后面加上dyld_decache具體路徑)

4.開始提取二進制文件(dyld_decache路徑/二進制提取之后存放路徑/armx路徑)

/Users/yuhan/Documents/appReverse/dyld_decache -o /Users/yuhan/Documents/appReverse/binarys /Users/yuhan/Documents/appReverse/dyld_shared_cache_armv7s 

四.dumpdecrypted砸殼工具

由于從AppStore下載的App是被蘋果加密過的,class-dump無法作用于加密過的App,所以想要獲取頭文件,需要先解密App的可執(zhí)行文件,俗稱"砸殼",dumpdecrypted就是一款砸殼工具.
1.下載dump decrypted源碼 依次執(zhí)行下面的命令

1)cd本地存儲路徑
2)git clone git://github.com/stefanesser/dumpdecrypted/
3)下載完成后 cd dumpdecrypted的路徑 
4)make
  make命令執(zhí)行完畢,會在當前目錄生成dumpdecrypted.dylib文件,用于砸殼

2.關閉所有應用 開啟需要砸殼的App

bogon:~ yuhan$ ssh root@iOSIP地址
ximengde-iPhone:~ root# ps -e(打印所有進程,找到目標app)
cycript -p TargetApp // 附加該進程 
(執(zhí)行此命令之前要保證Cydia中安裝了Cycript,否則會出現(xiàn)-sh: cycript: command not found)
cy# [[NSFileManager defaultManager ] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]
利用cy語言找到目標app的沙盒路徑
control+d退出cy#

3.開始砸殼

將dumpdecrypted.dylib拷貝到Documents目錄下
bogon:~ yuhan$ scp /Users/yuhan/Documents/appReverse/dumpdecrypted/dumpdecrypted.dylib root@iOSIP:/var/mobile/Containers/Data/Application/3E9A4A3E-0191-48EA-BA15-D135D892C505/Documents/

ximengde-iPhone:/var/root mobile$ su mobile(為了避免在執(zhí)行砸殼命令時出現(xiàn)killed:9的錯誤)
Password:
ximengde-iPhone:/var/root mobile$ cd
ximengde-iPhone:~ mobile$ cd /var/mobile/Containers/Data/Application/3E9A4A3E-0191-48EA-BA15-D135D892C505/Documents/                                                     
ximengde-iPhone:~/Containers/Data/Application/3E9A4A3E-0191-48EA-BA15-D135D892C505/Documents mobile$ DYLD_INSERT_LIBRARIES=dumpdecrypted.dylib /var/containers/Bundle/Application/0E619483-4AC3-430E-AADB-AD2B164FF1B3/Eyepetizer.app/Eyepetizer

4.查看砸殼結(jié)果

mach-o decryption dumper

DISCLAIMER: This tool is only meant for security research purposes, not for application crackers.

[+] detected 64bit ARM binary in memory.
[+] offset to cryptid found: @0x1000ccca8(from 0x1000cc000) = ca8
[+] Found encrypted data at address 00004000 of length 16744448 bytes - type 1.
[+] Opening /private/var/containers/Bundle/Application/0E619483-4AC3-430E-AADB-AD2B164FF1B3/Eyepetizer.app/Eyepetizer for reading.
[+] Reading header
[+] Detecting header type
[+] Executable is a plain MACH-O image
[+] Opening Eyepetizer.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 ca8
[+] Closing original file
[+] Closing dump file
ximengde-iPhone:~/Containers/Data/Application/3E9A4A3E-0191-48EA-BA15-D135D892C505/Documents mobile$ ls
5d441558f8bc24dcd9098fc926ca73d0  BNCServerRequestQueue  Eyepetizer.decrypted  WDJUsers.plist          com.tumblr.TMDiskCache.26d0363b2698b43f37da588e8c0e0119
76a378e14109fdcebb0f4c40f0464293  Config         QQApi.log         backgroundresource.dat  dumpdecrypted.dylib
BNCPreferences            Configcmsinfo.plist    TCSdkConfig.plist     clicked_msgIds???file   wdj_eyepetizer.sqlite

Eyepetizer.decrypted就是砸殼后我們需要的文件

5.將文件拷貝到電腦中

bogon:~ yuhan$ scp root@iOSIP:/var/mobile/Containers/Data/Application/3E9A4A3E-0191-48EA-BA15-D135D892C505/Documents/Eyepetizer.decrypted /Users/yuhan/Documents/appReverse/code 
root@iOSIP's password: 
Eyepetizer.decrypted                          100%   20MB   3.9MB/s   00:05    

把文件拷貝到OSX 用class-dump Hopper分析文件

?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容