大家知道app 有安卓和ios
安卓是apk 现在基本上apk都是经过加密的 想动态脱壳没一定的技术是搞不定的
IOS是ipa 今天我主要讲的是这个
准备好反编译设备
1.一套越狱的ios手机 我的设备是iphone6 ios8.3 已越狱
2.一个mac系统 可以是vmware上的mac 黑苹果 或者直接用自己的mac电脑 我为了方便就用了黑苹果(如何搞黑苹果可以看我之前发表的博客)
给大家看下我的环境吧:


准备反编译环境
1. 越狱手机上
1.1 Cydia上面安装 OpenSSH 安装成功后 可以remote到你的手机 默认的密码是 alpine

1.2 github上下载clutch然后放置在手机的 bin目录下(可以使用Itools工具)

解释一下这个工具是干什么的:如果app是直接从appstore下载的话 默认会被加密的 那么你用反编译工具IDA(下面会说到)的话就不行。得用这个工具解密生成一个ipa
2. mac机器上面准备好 LLDB Remote Debug 环境 (lldb是什么具体可以搜索Google)
2.1 配置Debug Server
从 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/ DeviceSupport/7.0.3\ \(11B508\)/DeveloperDiskImage.dmg 获得debugserver 然后复制到桌面(中间的那个 DeviceSupport 可以根据具体路径替换)

2.2 光有这个不行 还得弄下签名
创建一个 文件叫 Entitlements.plist 然后用 xcode打开进行编辑写入

输入命令 codesign -s - --entitlements entitlements.plist -f debugserver 之后 把这个 debugserver 传回 手机设备 的 /usr/bin/debugserver (可以使用Itools工具)

3. windows系统上安装反编译利器IDA工具,大家可以百度搜破解版

反编译实验开始
在mac系统上 ssh连接 手机设备

如果你的app是从appstore上下载的那么请先用clutch解密 【我这里就举了一个Discord程序的例子】
1 用clutch -i 命理 找到你安装的app的编号

2 用clutch -d 2命令进行解密操作

由于某头条我是从越狱版本Itools上下载的 本身就已经解密过了 所以不需要上面的操作
我直接用Itools导出ipa包

打开 Fiddler 进行抓包分析(如何配置手机代理请自行百度了)
打开app的注册页面

这里有一个获取验证码的图片的请求

请求的url里面有一个sign参数 一看就知道这个是md5加密
接下来我们就是要拿到这个md5是如何生成的
用IDA打开ipa包(第一次打开需要花点时间)
按SHift+F12打开 搜索String关键字 "sign"

双击进入

继续双击进入 Function

按 F5

这里我们可以得知 加密的类叫 BFCrytor 里面有一个 MD5方法
在Function列表搜索一下 果然有

好了 已经成功找到了 加密md5的类和方法名称了
接下来开始最重要的步骤了 要根据 类和方法名称找到 程序运行的 内存地址 然后对这个内存地址进行下断点
1.把ipa包copy到mac系统里面 然后 用 Class-DumpXApp -H -A -S -oheaders/
dump出来的头文件里面标记了 IMP 的地址 输入到 header文件夹
在该文件夹搜索刚刚我们找到的类名称 BFCryptor 用Xcode打开


记录下这个内存地址 0x0000000100241e30
lldb 挂载
用 px -a 命令找到 app 运行的 id

然后用命令执行挂载 执行完后 发现app被卡主了 一切都静止了

再打开另外一个bash 执行本地命令
> lldb> platform select remote-ios> process connect connect://iOSIP:8888
过一会儿就会看到下面这个就代表挂载成功

获取 ASLR 偏移量

那么 断线的内存地址 的算法 就是 基址 + 偏移量
也就是md5 方法的内存地址 = 0x00000000000fc000 + 0x0000000100241e30
用下面的命令进行下断点

断点下完后 执行 c 命令 让 app 跑起来 触发一个网络请求 就会发现 断点停下来的

用 po 命令打印参数 发现 arg3就是我们md5加密前的数据

接下来 就写一个模拟请求实验一下


请求成功了!!!!!
总结:
这篇文章给大家讲了 如何配置反编译环境
反编译一个app 拿到加密方式的一般步骤是怎样的。
md5的方式还是比较简单的,用rsa算法加密(例如国寿app,12306app等)的就比较难。但是方法都是一样的。
祝大家好运!