逆向工程

应用砸壳

Posted by JT on May 25, 2018

应用砸壳

壳是应用程序加密保护的一种方式。

为什么要砸壳

  1. class-dump无法作用于加密过得文件
  2. IDA无法对加壳的文件进行分析

查看文件是否加壳

查看文件是否加壳:

otool -l WeChat | grep cryptid

查看可执行文件的加密标识:

otool -l leapParent | grep crypt

     cryptoff 16384
    cryptsize 6144000
      cryptid 1              // 加密标识
     cryptoff 16384
    cryptsize 6389760
      cryptid 1              // 加密标识

查看可执行文件的架构

lipo -info leapParent

砸壳工具

Dumpdecrypted

一个源文件,编译后生成一个动态库文件,注入到我们的应用中,应用启动的时候会把解密后的文件写入到另一个文件夹中。

操作步骤:

  1. 下载编译dumpdecrypted,执行make命令
  2. 找到应用的沙盒目录,如Documents目录,用来写解密后的文件
  3. 注入dylib

工具1

工具2

Clutch

可执行文件,工具

  • GitHub下载最新版
  • 把下载的Clutch放到越狱的手机的/usr/bin目录下 scp -P 2222 Clutch-2.0.4 root@localhost:/usr/bin
  • 进入目录,输入Clutch
chaoge:/usr/bin root# Clutch-2.0.4
-sh: /usr/bin/Clutch-2.0.4: Permission denied

这里是因为没有赋予Clutch可执行权限

chaoge:/usr/bin root# chmod +x Clutch-2.0.4
chaoge:/usr/bin root# Clutch-2.0.4
Usage: Clutch-2.0.4 [OPTIONS]
-b --binary-dump <value> Only dump binary files from specified bundleID 
-d --dump <value>        Dump specified bundleID into .ipa file 
-i --print-installed     Print installed applications 
   --clean               Clean /var/tmp/clutch directory 
   --version             Display version and exit 
-? --help                Display this help and exit 
-n --no-color            Print with colors disabled 

可以看出这里是一些Clutch的命令使用,我们找到我们需要砸壳的App的bundleID,

chaoge:/usr/bin root# Clutch-2.0.4 -i
Installed apps:
1:   百词斩-背单词、学英语必备 <com.chaoui.jiongji100CN>
2:   淘宝 - 移动生活社区 <com.taobao.taobao4iphone>
3:   乐词 - 新东方背单词,学英语神器 <cn.xdf.leci>
4:   QQ <com.tencent.mqq>
5:   微信 <com.tencent.xin>
6:   搜狗输入法-语音输入文字扫描 <com.sogou.sogouinput>
7:   爱思加强版 <com.pd.A4Player>
8:   闲鱼 - 闲置二手游起来 <com.taobao.fleamarket>
9:   墨墨背单词 | 四六级考研等英语词汇记忆 <com.maimemo.ios.momo>

砸壳,然后会告诉你砸壳之后的.ipa文件的路径

chaoge:/usr/bin root# Clutch-2.0.4 -d cn.xdf.leci
Zipping leci.app
ASLR slide: 0x1000a0000
Dumping <leci> (arm64)
Patched cryptid (64bit segment)
Writing new checksum
DONE: /private/var/mobile/Documents/Dumped/cn.xdf.leci-iOS9.0-(Clutch-2.0.4).ipa
Finished dumping cn.xdf.leci in 19.5 seconds