当前位置:网站首页>Charles -- 从0-1教你如何使用抓包工具
Charles -- 从0-1教你如何使用抓包工具
2022-07-28 23:42:00 【么贺贵】
1. 安装
去官网下载,地址:https://www.charlesproxy.com/download/
2. 激活
这里是网上找的激活账号,填入即可
![Registered Name: https://zhile.io
License Key: 48891cf209c6d32bf4 ])
3. 配置
3.1 证书安装
Help->ssl proxying
- Charles Root Certificate
- Charles Root Certificate in iOS Simulators
- 钥匙串中改为始终信任

- iphone证书安装

打开Charles Root Certificate on a Mobile Device or Remote Browser,会出现如图
先配置代理,跳转3.2/3.3配置代理,配置完成后访问
Chls.pro/ssl
即会弹出框询问是否安装,同意安装即可。
不要高兴太早,安装完成要在手机设置->通用->关于本机->证书信任设置->charles Proxy CA,勾选开关,证书才生效。
3.2 代理设置
可以设置抓包数据类型,包括http与socket数据。可以根据需要在proxies栏下勾选。
如果需要抓Mac上的浏览器数据,需要在macOS栏,勾选http.
3.3 手机使用代理
手机连接局域网下wifi,与charles必须为同一外网下。
- 自动代理
在已连接的wifi上点击更多,进入配置代理页。勾选自动,在输入框URL中输入:
Https://chls.pro/10.10.11.235:6666.pac
即设置了自动代理。
- 手动代理
输入charles的ip与端口即可
3.4 HTTPS抓包
HTTPS抓包,需要经过SSL。
Proxy->SSL Proxy setting
会打开如下界面。点击Add,Host栏与Port栏都填空(表示抓所有SSL请求),确定即可。
注:如果未配置此项,在访问https数据的时候,你会发现访问失败,Structure栏显示小锁标识。
3.5 可接入控制
charles可以通过Access control Settings来控制允许访问列表。如果未允许本机器IP,访问不会走Charles,当然也抓不了包。
未配置过时,列表为空。当手机第一次访问时,charles会弹出是否允许弹框,点击allow,即同意此手机连接。
此手机的ip地址也会出现在Access control Settings的列表中。
我一般配置为允许所有,在Access control Settings中Add,输入0.0.0.0/0,添加即可。
3.5 Map Local
这个功能相当有用,可以把数据请求的response从本地文件获得。
比如:我有一个系统升级功能,升级方式upgradeType有三种:强制/普通/静默,然而,自己想要测试验证三种场景,就得麻烦后台去修改数据。这时候,Map Local可以上场了。
保存远端response:

设置Map Local:


打到保存的json文件,修改返回值:

然后重新请求,就会走你修改后的本地文件数据了。再也不用频繁麻烦后端同学了,自己就能模拟各种数据场景。
如何关闭?charles工具栏 -> Tools -> Map Local,点击进入
4. 一些常见问题
4.1 真机验证应用时卡住?
作为苹果开发,很多时候需要通过Xcode把自己做的小Demo运行到手机上,用的又是免费的个人证书,需要在手机上信任证书,及验证应用。如果你设置了抓包,ssl是验证不过的。
解决办法:
ssl时,只抓指定的网址,不要设置全抓* 。charles工具栏 -> Proxy -> SSL Proxy Settings,只抓项目后台地址。
5. 总结
把上面步骤过了,就可以愉快的抓https了。总结一下:
证书:Mac/模拟器/iphone证书(不要忘记信任证书)。
Proxy setting勾选HTTP与SOCKS。
同一局域网。
手机设置代理。
Access control Settings同意接入 SSL proxy添加星。
当然,charles功能不仅仅于此,非常强大,还有很多功能等待发现。如:断点/拦截,返回修改后数据/模拟断网/模拟网络差。
原文链接:https://www.jianshu.com/p/9f4ebde9c518
边栏推荐
- [basic course of flight control development 8] crazy shell · open source formation uav-i2c (laser ranging)
- About 1931cie -- conversion of XYZ color coordinate graph to RGB color coordinate relationship
- Method of converting inline elements to block elements
- selenium对接代理与seleniumwire访问开发者工具NetWork
- 将Word中的表格以图片形式复制到微信发送
- Wechat campus bathroom reservation for the finished product of applet graduation design (7) mid term inspection report
- Error reporting: Rong Lianyun sends SMS verification code message 500
- SQL server only has database files and no log files. The solution to the 1813 error in restoring data times
- 我不建议你使用SELECT *
- Jupyter notebook中5个有趣的魔法命令
猜你喜欢
![[AD learning] the course of PCB drawing in this marine vehicle competition](/img/37/211a0557848f6922fda7a69a114923.png)
[AD learning] the course of PCB drawing in this marine vehicle competition

用CDO进行nc数据的不规则裁剪

Selenium docking agent and selenium wire access developer tool network

SystemVerilog-连接和复制运算符

【无标题】

Outlier detection and Gan network (1)

数仓搭建——ADS层

伦敦金即时行情带来什么机会?

Yield Guild Games:这一年的总结与未来展望

Irregular clipping of NC data with CDO
随机推荐
管理区解耦架构见过吗?能帮客户搞定大难题的
保护性拷贝&无状态
【无标题】
伦敦金即时行情带来什么机会?
Techo Hub 福州站干货来袭|与开发者共话工业智能新技术
redis版本怎么查看(查看redis进程)
[development tutorial 11] crazy shell · open source Bluetooth heart rate waterproof sports Bracelet - explanation of the function code of the whole machine
Data warehouse construction - ads floor
Method of converting inline elements to block elements
深度学习 | MATLAB实现TCN时间卷积神经网络spatialDropoutLayer参数描述
Yield Guild Games:这一年的总结与未来展望
Copy the table in word to wechat as a picture and send it
Andriod6.0 low power mode (turn off WiFi, Bluetooth, GPS, screen brightness, etc.)
Consumer unit 消费单元
【愚公系列】2022年07月 Go教学课程 020-Go容器之数组
[network security] complete the blacklist and whitelist functions of server firewall through iptables and ipset
用CDO进行nc数据的不规则裁剪
iNFTnews | 元宇宙购物体验将成为吸引消费者的一大利器
Some considerations about ThreadPool
Download the latest version of visual studio code and connect to the server remotely (very detailed)