iOS 逆向 - 使用 dumpdecrypted 給 APP 砸殼

iOS 逆向 - 使用 dumpdecrypted 給 APP 砸殼

對 Google Sheets 進行砸殼

iDevice: iPod (armv7)
System: iOS 8.1

  1. 找到 TargetApp 的 Documents 目錄(在設備上操作)
  2. dumpdecrypted.dylib 拷貝到 TargetApp 的 Docuemnts 目錄下(在 Mac 上操作)
  3. dumpdecrypted.dylib 砸殼(在設備上操作)
  4. 將砸殼后的 TargetApp.decrypted 拷貝回本地 Mac(在 Mac 上操作)

找到 TargetApp 的 Documents 目錄(在設備上操作)

找到你想要砸殼的 app

ps: 需要在 Cydia 中安裝 MobileTerminal 和 Cycript

  1. 將設備上所有其他的 app 都關掉朵纷,只打開你想要砸殼的 TargetApp(如筆者想要砸殼的 Sheets)贝润。
  2. 通過 ps 命令查看當前在運行的進程,配合 grep 命令找到 TargetApp诉字。可以 grep AppName 或者 grep Containers蜻底,后者不用輸入 TargetApp 的名字氮块,畢竟有一些名字不好輸入,筆者用的是后面的方法校哎。
  3. 使用 cycript 注入 TargetApp两波。可以使用 cycript -p AppPIDcycript -p AppName 兩種方式指定要注入的 TargetApp闷哆。名字可能不是唯一的腰奋,有可能失敗。筆者傾向于用 PID 的方法抱怔。
  4. 出現(xiàn) cy# 即說明進入了 cycript 的環(huán)境劣坊。
MyiPod:~ root# ps -e | grep Containers
 2527 ??         0:08.64 /var/mobile/Containers/Bundle/Application/5C6D0D63-82B0-442B-BCB3-97B800369FCD/Sheets.app/Sheets
 2530 ttys000    0:00.01 grep Containers
MyiPod:~ root# cycript -p 2527
cy#

找到 App 的 Document 所在目錄

使用 OC 的方法 [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomans:NSUserDomainMask][0] ,直接將 TargetApp 的 Document 目錄打印出來屈留。

cy# [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomans:NSUserDomainMask][0]
#"file:///var/mobile/Containers/Data/Application/397CCFE0-69E0-43B1-8894-8F0BB0152656/Documents/"
cy# 

ps: Ctrl+D 退出 cycript

dumpdecrypted.dylib 拷貝到 TargetApp 的 Docuemnts 目錄下(在 Mac 上操作)

dumpdecrypted.dylib 從 Mac 中拷貝到 iPod 的 Documents 目錄局冰。該目錄有讀寫權限,我們需要寫入權限灌危,把砸殼后的數(shù)據(jù)先寫到 Documents 目錄下康二。

likids-MBP:~ Likid$ scp /Develop/iOSRE/dumpdecrypted.dylib root@172.20.10.9:/var/mobile/Containers/Data/Application/397CCFE0-69E0-43B1-8894-8F0BB0152656/Documents/
root@172.20.10.9's password: 
dumpdecrypted.dylib                           100%  193KB 192.9KB/s   00:00    

dumpdecrypted.dylib 砸殼(在設備上操作)

在 iPod 中進行砸殼,獲得 Sheets.decrypted勇蝙。

  1. cd 進入 TargetApp 的 Documents 目錄
  2. 查看 dumpdecrypted.dylib 是否已經(jīng)拷貝到 Documents 下
  3. dumpdecrypted.dylib 注入 TargetApp沫勿,會自動進行砸殼,輸出砸殼后的 app TargetApp.decrypted,如 Sheets.decrypted
MyiPod:~ root# cd /var/mobile/Containers/Data/Application/397CCFE0-69E0-43B1-8894-8F0BB0152656/Documents/
MyiPod:/var/mobile/Containers/Data/Application/397CCFE0-69E0-43B1-8894-8F0BB0152656/Documents root# ls
112161084947550660392/  drivekit/  dumpdecrypted.dylib*
MyiPod:/var/mobile/Containers/Data/Application/397CCFE0-69E0-43B1-8894-8F0BB0152656/Documents root# DYLD_INSERT_LIBRARIES=dumpdecrypted.dylib /var/mobile/Containers/Bundle/Application/5C6D0D63-82B0-442B-BCB3-97B800369FCD/Sheets.app/Sheets
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: @0x7fa08(from 0x7f000) = a08
[+] Found encrypted data at address 00004000 of length 49872896 bytes - type 1.
[+] Opening /private/var/mobile/Containers/Bundle/Application/5C6D0D63-82B0-442B-BCB3-97B800369FCD/Sheets.app/Sheets 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 Sheets.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 4a08
[+] Closing original file
[+] Closing dump file
MyiPod:/var/mobile/Containers/Data/Application/397CCFE0-69E0-43B1-8894-8F0BB0152656/Documents root# ls
112161084947550660392/  Sheets.decrypted  drivekit/  dumpdecrypted.dylib*
MyiPod:/var/mobile/Containers/Data/Application/397CCFE0-69E0-43B1-8894-8F0BB0152656/Documents root# 
MyiPod:/var/mobile/Containers/Data/Application/397CCFE0-69E0-43B1-8894-8F0BB0152656/Documents root# exit

將砸殼后的 TargetApp.decrypted 拷貝回本地 Mac(在 Mac 上操作)

Sheets.decrypted 拷貝回本地 Mac产雹,查看是否砸殼成功烫罩,cryptid 為 0 則表示砸殼成功,該架構沒有加密

likids-MBP:~ Likid$ scp root@172.20.10.9:/var/mobile/Containers/Data/Application/397CCFE0-69E0-43B1-8894-8F0BB0152656/Documents/Sheets.decrypted /Develop/iOSRE/Sheets/
root@172.20.10.9's password: 
Sheets.decrypted                              100%  141MB   1.8MB/s   01:19    
likids-MBP:~ Likid$ cd /Develop/iOSRE/Sheets/
likids-MBP:Sheets Likid$ ls
Sheets.decrypted
likids-MBP:Sheets Likid$ file Sheets.decrypted 
Sheets.decrypted: Mach-O universal binary with 2 architectures: [arm_v7: Mach-O executable arm_v7] [arm64]
Sheets.decrypted (for architecture armv7):  Mach-O executable arm_v7
Sheets.decrypted (for architecture arm64):  Mach-O 64-bit executable arm64
likids-MBP:Sheets Likid$ otool -l Sheets.decrypted | grep crypt
Sheets.decrypted (architecture armv7):
     cryptoff 16384
    cryptsize 49872896
      cryptid 0
Sheets.decrypted (architecture arm64):
     cryptoff 16384
    cryptsize 53395456
      cryptid 1

ref: 《iOS應用逆向工程(第2版)》

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末洽故,一起剝皮案震驚了整個濱河市贝攒,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌时甚,老刑警劉巖隘弊,帶你破解...
    沈念sama閱讀 218,755評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異荒适,居然都是意外死亡梨熙,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,305評論 3 395
  • 文/潘曉璐 我一進店門刀诬,熙熙樓的掌柜王于貴愁眉苦臉地迎上來咽扇,“玉大人,你說我怎么就攤上這事陕壹≈视” “怎么了?”我有些...
    開封第一講書人閱讀 165,138評論 0 355
  • 文/不壞的土叔 我叫張陵糠馆,是天一觀的道長嘶伟。 經(jīng)常有香客問我,道長又碌,這世上最難降的妖魔是什么九昧? 我笑而不...
    開封第一講書人閱讀 58,791評論 1 295
  • 正文 為了忘掉前任,我火速辦了婚禮毕匀,結果婚禮上铸鹰,老公的妹妹穿的比我還像新娘。我一直安慰自己皂岔,他們只是感情好蹋笼,可當我...
    茶點故事閱讀 67,794評論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著凤薛,像睡著了一般姓建。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上缤苫,一...
    開封第一講書人閱讀 51,631評論 1 305
  • 那天速兔,我揣著相機與錄音,去河邊找鬼活玲。 笑死涣狗,一個胖子當著我的面吹牛谍婉,可吹牛的內容都是我干的。 我是一名探鬼主播镀钓,決...
    沈念sama閱讀 40,362評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼穗熬,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了丁溅?” 一聲冷哼從身側響起唤蔗,我...
    開封第一講書人閱讀 39,264評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎窟赏,沒想到半個月后妓柜,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,724評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡涯穷,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 37,900評論 3 336
  • 正文 我和宋清朗相戀三年棍掐,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片拷况。...
    茶點故事閱讀 40,040評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡作煌,死狀恐怖,靈堂內的尸體忽然破棺而出赚瘦,到底是詐尸還是另有隱情粟誓,我是刑警寧澤,帶...
    沈念sama閱讀 35,742評論 5 346
  • 正文 年R本政府宣布蚤告,位于F島的核電站努酸,受9級特大地震影響,放射性物質發(fā)生泄漏杜恰。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,364評論 3 330
  • 文/蒙蒙 一仍源、第九天 我趴在偏房一處隱蔽的房頂上張望心褐。 院中可真熱鬧,春花似錦笼踩、人聲如沸逗爹。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,944評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽掘而。三九已至,卻和暖如春于购,著一層夾襖步出監(jiān)牢的瞬間袍睡,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,060評論 1 270
  • 我被黑心中介騙來泰國打工肋僧, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留斑胜,地道東北人控淡。 一個月前我還...
    沈念sama閱讀 48,247評論 3 371
  • 正文 我出身青樓,卻偏偏與公主長得像止潘,于是被迫代替她去往敵國和親掺炭。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 44,979評論 2 355

推薦閱讀更多精彩內容