- 一是拦截别人软件的发送的请求和后端接口,练习开发。
- 二是自己后端返回的response拦截修改后再接收以达到测试临界数据的作用。
- 三写脚本重复拦截抓取别人的数据。
- 四支持流量控制,可以模拟慢速网络以及等待时间(latency)较长的请求。
- 五支持重发网络请求,方便后端调试。
- 六支持SSL代理。可以截取分析SSL的请求。
作者:Adminwang
链接:https://www.jianshu.com/p/90bdb565a1a4
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
1. Charles安装
官网下载安装Charles:
https://www.charlesproxy.com/download/
2. HTTP抓包
(1)查看电脑IP地址
![](https://upload-images.jianshu.io/upload_images/2469183-ff851ce2abe6cfe8.png?imageMogr2/auto-orient/strip%7CimageView2/2)
(2)设置手机HTTP代理
手机连上电脑,点击“设置->无线局域网->连接的WiFi”,设置HTTP代理:
服务器为电脑IP地址:如192.168.1.169
端口:8888
![](https://upload-images.jianshu.io/upload_images/2469183-ad19fa10a1815cbc.png?imageMogr2/auto-orient/strip%7CimageView2/2)
设置代理后,需要在电脑上打开Charles才能上网
(3)电脑上打开Charles进行HTTP抓包
手机上打开某个App或者浏览器什么的,如果不能上网,检查前面步骤是否正确
![](https://upload-images.jianshu.io/upload_images/2469183-8630cf0087d20187.png?imageMogr2/auto-orient/strip%7CimageView2/2)
点击“Allow”允许,出现手机的HTTP请求列表
![](https://upload-images.jianshu.io/upload_images/2469183-874a256420dcae1f.png?imageMogr2/auto-orient/strip%7CimageView2/2)
HTTP抓包
3. HTTPS抓包
HTTPS的抓包需要在HTTP抓包基础上再进行设置
设置前抓包HTTPS是这样的
![](https://upload-images.jianshu.io/upload_images/2469183-81c9d7cd686f86eb.png?imageMogr2/auto-orient/strip%7CimageView2/2)
设置后抓包HTTPS长这样
![](https://upload-images.jianshu.io/upload_images/2469183-3b9210f6ea4c6403.png?imageMogr2/auto-orient/strip%7CimageView2/2)
![](https://upload-images.jianshu.io/upload_images/2469183-c83e45626a1cb35e.png?imageMogr2/auto-orient/strip%7CimageView2/2)
以下为在HTTP抓包基础上进行HTTP抓包的进一步设置步骤:
(1)安装SSL证书到手机设备
点击 Help -> SSL Proxying -> Install Charles Root Certificate on a Mobile Device
![](https://upload-images.jianshu.io/upload_images/2469183-8f47a1b1c1540ef7.png?imageMogr2/auto-orient/strip%7CimageView2/2)
出现弹窗得到地址 chls.pro/ssl
![](https://upload-images.jianshu.io/upload_images/2469183-c7f6ad4a204b0bd4.png?imageMogr2/auto-orient/strip%7CimageView2/2)
手机安装SSL证书的地址
在手机Safari浏览器输入地址 chls.pro/ssl,出现证书安装页面,点击安装
手机设置有密码的输入密码进行安装
![](https://upload-images.jianshu.io/upload_images/2469183-7ed4a5c8c2a36217.png?imageMogr2/auto-orient/strip%7CimageView2/2)
安装证书
- 注意1:有兄弟姐妹说Safari浏览器输入这个网址chls.pro/ssl安装不了证书的情况,
亲测要(1)设置好手机HTTP代理 (2)电脑上Charles要开着 - 注意2:iOS 10.3系统,需要在 设置→通用→关于本机→证书信任设置 里面启用完全信任Charles证书