Use Charles to capture packets

This article records how to use Charles to capture packets on Mac, including two scenarios, capturing the request response data initiated on the computer application, and capturing the request response data initiated on the mobile device (IPhone).

Because Charles is developed in Java, the Java JDK must be installed on the computer. In the process of using Charles, if the VPN is turned on, you need to turn off the VPN.

Install

Click the link and select the Mac version to download and install: www.charlesproxy.com/download/

1. Configure the address where you want to capture data

Proxy → SSL Proxying Settings

The default setting is to capture the data of all HTTPS addresses, here it can be set to only capture the data of a specific address.

slideshow 1.jpg

2. Install the certificate on the computer

Help → SSL Proxying → Install Charles Root Certificate

slideshow 2.jpg

3. Set up HTTP and HTTPS proxy

System Preferences→ Network→ Advanced→ Proxy

The default port number is 8888, which is the same as the HTTP proxy port number in Proxy → Proxying Settings.

Slide 3.jpg

So far, the request and response data in the computer application can be captured (such as the request and response data in Google Chrome).

By the way, uncheck the Combine request and response option in Charles → Preferences → Viewers, and the application interface will display the request and response data separately, which looks more intuitive.

Next, let's take a look at how to capture the request response data in the mobile phone.

4. See the prompt to install the mobile device certificate in Charles on Mac

Help → SSL Proxying → Install Charles Root Certificate on a Mobile Device or Remote Browser

The pop-up box that prompts will give the IP address and port number of the computer. You need to configure the HTTP proxy in the mobile phone.

slideshow 4.jpg

5. Install the certificate on the iPhone

1. Configure HTTP proxy on the phone

Slide 5.jpg

After the configuration is complete, open any App on the phone to request data, and the Charles app on the computer will pop up a pop-up window, click Allow.

image-20220327135536739.png

2. Install the certificate

Open this link in Safari browser: chls.pro/ssl

Slide 6.jpg

The above is the whole configuration process. After the configuration is complete, you can start to capture data.

Reference address

zhuanlan.zhihu.com/p/26182135

Guess you like

Origin juejin.im/post/7079714541243727879