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. 出现 cy# 即说明进入了 cycript 的环境。
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 目录。该目录有读写权限,我们需要写入权限,把砸壳后的数据先写到 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 是否已经拷贝到 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版)》

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,736评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,167评论 1 291
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,442评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,902评论 0 204
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,302评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,573评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,847评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,562评论 0 197
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,260评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,531评论 2 245
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,021评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,367评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,016评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,068评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,827评论 0 194
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,610评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,514评论 2 269

推荐阅读更多精彩内容