技术分享iOS 逆向ASO相关

6.抓包工具--charles(青花瓷)及获取AppStore数

2018-06-08  本文已影响1035人  木子心语

1.Charles

charles--(青花瓷)

Charles是一个HTTP代理/ HTTP监视器/反向代理,使开发人员能够查看他们的机器和Internet之间的所有HTTP和SSL / HTTPS通信。这包括请求、响应和HTTP头(包含cookie和缓存信息)。

2.Charles 使用与配置

打开Charles,打开Charlels主题菜单,找到Proxy
勾选上macOS Proxy就可以了
在macOS Proxy 的下方有Proxy Settings选项,点击打开
在Port出输入8888,并且勾选下方Enable transparent HTTP proxying 选项,点击OK即可.
(设置中找到网络即可看到mac ip地址)

第二种:

(在Charles菜单栏中,找到Help-->Local IP Address,打开即可找到ip地址)

第三种:


(终端-->ifconfig)

3.抓取https包

菜单栏中找到Help-->SSL Proxying -->>Install Charies Root Certificate!
C6E600A0-161E-4AF2-8CAC-FA5E6EA88A1F.png
在钥匙串中,找到Charles Proxy 证书,这个是我信任后的证书
安装的后的证书是不被信任的.
信任证书
我们选中证书,右键,显示简介就可以出现上图,我们信任证书即可
然后输入mac密码确认.
证书到这里已经完成安装
SSL Proxying Settings
菜单栏--> Proxy --> SSL Proxying Settings
Host: * 
Port: 443
点击ok即可完成配置

4.Charles抓包工具的中文乱码解决办法

装好了,打开Charles后,发现抓到的包content都是乱码.
下面有个解决办法,有助于大家参考,解决了问题.


Rewrite
菜单栏找到-->Tools-->Rewrite
Enable Rewrite
开启Enable Rewrite ,添加charset
Name: UTF-8-Set
点击Add,添加内容
E6A6F6F7D8C8E5F365EC9111E33EB1F4.png
红框出添加或者勾选,点击ok即可完成配置.

我们的问题就可以解决了.

5. AppStore 数据包抓取

如果我们所有的配置都完成了,
我们是不是就可以愉快的抓包了.
当时的心情是开心的.
然而问题就来了,
到底是什么问题呢?
这么神秘吗?
这个问题算是神秘.

iTunes Store 与 App Store 登录 账号登录

我们到这一步都还OK,
想想不到的事情出现了,
当我们把密码和账号输入后,
点击登录按钮
提示连接apple 服务器 错误
一万个不开心.
当时AppStore 也打不开了,显示连接不到apple服务器.
其他软件可以正常抓取数据.
当时猜测是不是苹果做了反抓取机制.

后来,找了原因:越狱手机要禁止SSL Pinning证书,
AppStore使用的是SSL Pinnign(证书锁定),
所以没有办法通过抓包工具直接抓到包.
因此想抓到包,必须通过安装插件来禁止SSL Pinning.
这是目前最有效的解决方法了,不知道有没有用.
抱着尝试的目的开始操作.

ssl-kill-switch2 sslkillswitch--deb
scp com.nablac0d3.sslkillswitch2_0.12.deb  root@host:var/root/

安装sslkillswitch

dpkg -i  com.nablac0d3.sslkillswitch2_0.12.deb

安装中遇到的问题:


没有安装preferenceloader
主要cydia没有安装插件 preferenceloader
在cydia中找到该插件,并安装.就可以解决问题.
安装preferenceloader

安装完成后,手机会立即重启,重启后我们进入设置,最下面会多了一个SSL Kill Switch2

SSL Kill Switch 2 Disable Certificate Validation
Why SSL Kill Switch didn’t work

I initially thought the issue to be that the strategy used by the SSL Kill
Switchto disable certificate validation somehow wasn’t enough to 
bypass *itunesstored*’s certificate pinning. However, it turns out that the SSL 
Kill Switch was just not being injected into the *itunesstored* process at all, 
for a couple reasons:

The itunesstored process is started as a daemon by launchd early during 
the device’s boot sequence, before MobileSubstrate and MobileLoader get 
started. Therefore, none of the MobileSubstrate tweaks installed on the 
device, including the SSL Kill Switch, get injected into this process.
The SSL Kill Switch had a MobileLoader filter so that the code disabling 
certificate validation would only be loaded into apps linking the UIKit bundle 
(ie. applications with a user interface). This was initially done to restrict the 
effect of the SSL Kill Switch to App Store apps only. 
However, itunesstored is a daemon that doesn’t have a user interface, 
hence the filter prevented MobileLoader from injecting the SSL Kill Switch 
into the process.
After figuring this out, getting *itunesstored* to stop validating SSL 
certificates was very straightforward. First of all, make sure you’re using the 
latest version of the SSL Kill Switch(at least v0.5). Then, all you need to do is 
kill the itunesstored process:
iPad-Mini:~ root# ps -ef | grep itunesstored
501   170     1   0   0:00.00 ??         0:01.95 /System/Library/PrivateFrameworks/iTunesStore.framework/Support/itunesstored
  0   432   404   0   0:00.00 ttys000    0:00.01 grep itunesstored

iPad-Mini:~ root# kill -s KILL 170

原因是tunesstored进程在早期启动时作为守护进程启动
该设备的引导序列,在MobileSubstrate和MobileLoader获得之前开始了.
因为SSL Kill Switch作为MobileSubstrate的插件,没有办法注入到进程itunesstored中.
如何解决:
必须杀掉itunesstored进程,itunesstored作为守护进程会自启,自启时SSL Kill Switch 就注入了itunesstored进程,如何操作呢?
其实上面文章也给出了操作命令.
我们自己也操作一下.

kill进程

kill进程后,我们重启App Store,就可以愉快的抓包了.
我当时第一次操作后,并没有任何结果.
我自己开始觉得这个方法没有解决问题.
后来,我尝试关机重启,
然后再操作一次kill命令,
最后,完全正常了.
如果大家也是这样,可以重启手机多次,多操作几次.
如果没有其他的解决办法,这就是唯一的好方法.

6.总结

因为最近要抓取AppStore的数据包,
也就研究了一下Charles,
刚接触就遇到了这些问题,
所以把自己的解决办法告诉大家,
希望大家少走弯路,
节省更多的时间.

本文章简单的介绍了,
charles 的配置及使用,
AppStore的数据报获取.
还有很多charles的功能待你去研究.
这篇文章希望能够能帮到你.
如果喜欢文章,请来一波赞和鲜花.
有很多文章准备更新,请你持续关注.
有更多的惊喜带给你.

上一篇下一篇

猜你喜欢

热点阅读