- Charles安装
- HTTP抓包
- HTTPS抓包
![](http://upload-images.jianshu.io/upload_images/2469183-c422573ff7075723.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/660)
1. Charles安装
官网下载安装Charles:
https://www.charlesproxy.com/download/
2. HTTP抓包
(1)查看电脑IP地址
![](http://upload-images.jianshu.io/upload_images/2469183-ff851ce2abe6cfe8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/672)
(2)设置手机HTTP代理
手机连上电脑,点击“设置->无线局域网->连接的WiFi”,设置HTTP代理:
服务器为电脑IP地址:如192.168.1.169
端口:8888
![](http://upload-images.jianshu.io/upload_images/2469183-ad19fa10a1815cbc.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/350)
设置代理后,需要在电脑上打开Charles才能上网
(3)电脑上打开Charles进行HTTP抓包
手机上打开某个App或者浏览器什么的,如果不能上网,检查前面步骤是否正确
![](http://upload-images.jianshu.io/upload_images/2469183-8630cf0087d20187.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
点击“Allow”允许,出现手机的HTTP请求列表
![](http://upload-images.jianshu.io/upload_images/2469183-874a256420dcae1f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
�HTTP抓包
3. HTTPS抓包
HTTPS的抓包需要在HTTP抓包基础上再进行设置
设置前抓包HTTPS是这样的
![](http://upload-images.jianshu.io/upload_images/2469183-81c9d7cd686f86eb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/636)
设置后抓包HTTPS长这样
![](http://upload-images.jianshu.io/upload_images/2469183-3b9210f6ea4c6403.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/626)
![](http://upload-images.jianshu.io/upload_images/2469183-c83e45626a1cb35e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
以下为在HTTP抓包基础上进行HTTP抓包的进一步设置步骤:
(1)安装SSL证书到手机设备
点击 Help -> SSL Proxying -> Install Charles Root Certificate on a Mobile Device
![](http://upload-images.jianshu.io/upload_images/2469183-8f47a1b1c1540ef7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
出现弹窗得到地址 chls.pro/ssl
![](http://upload-images.jianshu.io/upload_images/2469183-c7f6ad4a204b0bd4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/699)
手机安装SSL证书的地址
在手机Safari浏览器输入地址 chls.pro/ssl,出现证书安装页面,点击安装
手机设置有密码的输入密码进行安装
![](http://upload-images.jianshu.io/upload_images/2469183-7ed4a5c8c2a36217.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/249)
�安装证书
-
注意1:有兄弟姐妹说Safari浏览器输入这个网址chls.pro/ssl安装不了证书的情况,
亲测要(1)设置好手机HTTP代理 (2)电脑上Charles要开着 -
注意2:iOS 10.3系统,需要在 设置→通用→关于本机→证书信任设置 里面启用完全信任Charles证书
(这里感谢@13002171223的提出这点 ,之前没升级10.3哈)
(2)�Charles设置Proxy
Proxy -> SSL Proxying Settings...
![](http://upload-images.jianshu.io/upload_images/2469183-2c460b4652797ccf.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/549)
勾选Enable SSL Proxying,点击Add
![](http://upload-images.jianshu.io/upload_images/2469183-11eb2be75eae13fb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/592)
Host设置要抓取的https接口,比如想抓这个
![](http://upload-images.jianshu.io/upload_images/2469183-b39831342a11daca.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/285)
Host填写:https://api.weibo.cn
Port填写:443
![](http://upload-images.jianshu.io/upload_images/2469183-ca37de9cdb920511.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
(3)进行HTTPS抓包
让手机重新发送https请求,可看到抓包
![](http://upload-images.jianshu.io/upload_images/2469183-5f1b21912781d466.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/700)
HTTPS抓包
注意:不抓包请关闭手机HTTP代理,否则断开与电脑连接后会连不上网