Use Charles to capture packets on Mac/iOS

1. Preparations

  • Install JDK

Charles is developed by Java, please install the JDK first (the author's JDK version is 1.8.0_91).

  • DownloadCharles

Official website download address , the latest version 4.0.2 supports macOS 10.7 - 10.12 (the author's macOS version is 10.12.4).

  • Turn off VPN/proxy

In order to use Charles normally, please turn off your VPN or other proxy settings.

2. Charles configuration


1. Install the certificate
To grab the PC request, you need to install the certificate: install Charles Root Certificate

 After the installation is complete, manually set the trust certificate

insert image description here 

2. Capture HTTPS request settings-SSL Proxying Settings 
set Host to *, which means to capture requests from all domains;
set port to 443, which means to capture HTTPS requests

After the setting is complete, click to check it to enable it, and click ok again.

3. Set system proxy


​After installing Charles, if you directly capture the packet without setting the system proxy, you will not be able to capture any information

Method 1: Direct setting

Method 2: Manual setting

System Preferences - Network - Advanced - Proxy: 

 At this point, you can successfully capture packets on the PC side 

insert image description here

4. Proxy settings for capturing packets on the mobile phone


1. Install the certificate
1.1 Download the certificate

The option to download all the mobile phone capture packages from Android

  • Set up the charles proxy of the mobile phone (make sure that the mobile phone and the computer are under the same domain name)
  • Visit http://chls.pro/ssl to download the certificate


The downloaded certificate suffix needs to be crt, if not, try the following methods: 

  • PC download, and then transfer to the mobile phone
  • Android can rename files downloaded using UC browser

1.2 Certificate trust

Open Phone Settings - Security - More Security Settings - Encryption and Credentials - Install from Storage Device - Find the corresponding certificate, click to display the following picture, click OK, it will prompt that the installation is successful.

Open phone settings - general - about this machine - certificate trust settings - enable the newly installed certificate "Enable full trust for the root certificate" option

 

To check whether the installation is successful, you can open the phone settings again - Security - More Security Settings - Encryption and Credentials - You can view the installed Charles certificate from trusted credentials and user credentials, which can prove that the certificate installation and trust are successful

2. Open the Charles proxy-Proxy Settings

  • Port setting 8888
  • Check Enable transparent HTTP proxying
  • click ok

 3. Packet capture agent operation
3.1 View PC IP

3.2 Turn on the mobile phone to set the agent

Settings-WLAN-Modify network-Proxy setting to manual-fill in the above ip and port, click OK to set successfully, then you can successfully see the successful interface of packet capture.

Guess you like

Origin blog.csdn.net/DY_CSDN/article/details/130015734