Charles profile

Charles is a common network packet interception tool on PC. In mobile development, we often need to intercept network packets for analysis in order to debug the network communication protocol with the server. In addition to debugging ports for mobile development, Charles can also be used to analyze communication protocols for third-party applications. In conjunction with Charles’ SSL capabilities, Charles can also analyze the Https protocol.

Charles implements interception and analysis of network packets by setting himself up as the network access proxy server of the system, through which all network access requests are processed.

Charles is a paid software with a 30-day free trial. After the trial period, users who have not paid will still be able to use the app for no more than 30 minutes at a time, and there will be a 10-second delay on startup. Therefore, the payment plan is quite user friendly, even if you don’t pay for a long time, you can still use the full software features. However, when you need to do packet debugging for a long time, you will be affected by Charles forcing the shutdown.

The main functions of Charles include:

  • Intercepts Http and Https network packets.
  • Supports resending network requests, facilitating back-end debugging.
  • Network request parameters can be modified.
  • Support network request interception and dynamic modification.
  • Support analog slow network.

Install Charles

  • Windows 64 bit(msi)
  • Windows 32 bit(msi)
  • macOS(dmg)
  • Linux 64 bit(tar.gz)
  • Linux 32 bit(tar.gz)

Open the browser to visit the official website of Charles, download the Charles installation package of the corresponding system, and then install:

  • Windows: Run the Install application to install Charles in the Program menu.
  • Mac OS X: Unzip the downloaded file by double-clicking, then copy the Charles application into the Applications directory.
  • Linux:Charles hasAPT 和 YUMRepository if you have a baseDebianOr based onRed HatThis is the preferred method of installing Charles. Otherwise, ittar.gzUnzip the file to the appropriate site. If you have previously installed Charles and are upgrading; First make sure Charles is not running, then install or copy the previous install. By running thebin/charlesThe script starts Charles.

If you use Firefox, you can also download the Firefox plug-in. Refer to the Firefox Add – On

Charles main interface introduction

The main view of Charles is shown below:

Navigation bar

Charles has a menu navigation bar at the top and a tool navigation bar at the bottom. The view is as follows:

  • : Clears all captured requests
  • : The red dot indicates that a request is being captured. The gray state indicates that no request is being captured.
  • : Grey indicates that network speed throttling is disabled. Green indicates that network speed throttling is enabled.
  • : Gray indicates that the breakpoint is not enabled. Red indicates that the breakpoint is enabled.
  • : Edit modify request, click to modify the content of the request.
  • : To send the request repeatedly. After clicking, the selected request will be sent again.
  • : verifies the response to the selected request.
  • : Common functions, including common functions in the Tools menu.
  • : Common Settings, including common Settings in the Proxy menu.

Main View

Charles provides two main views for viewing packets, called Structure and Sequence.

  • Structure: This view classifies network requests by domain names accessed.
  • Sequence: This view sorts network requests by access time.

You can switch back and forth between the two views depending on your needs. Charles provides a simple Filter function that allows you to enter a keyword to quickly Filter out web requests with a specified keyword in the URL.

For a specific network request, you can view the detailed request content and response content. If the request content is a POST form, Charles will automatically display the form for you. If the response is in JSON format, Charles can automatically format the JSON content for you to view. If the response content is an image, Charles can display a preview of the image.

Charles Menu Introduction

Charles’ main menu includes: File, Edit, View, Proxy, Tools, Window, and Help. The most commonly used main menus are Proxy and Tools respectively.

The Proxy menu

Charles is an HTTP and SOCKS proxy server. Proxy requests and responses enable Charles to examine and change requests as they pass from the client to the server, and responses as they pass from the server to the client. Here are some of the proxy features provided by Charles. The view of the Proxy menu is shown below:

The Proxy menu contains the following functions:

  • Start/Stop Recording: Starts or stops Recording a session.
  • Start/Stop Throttling: Starts/stops Throttling.
  • Enable/Disable Breakpoints: Enables or disables breakpoint mode.
  • Recording Settings: Recording session Settings.
  • Throttle Settings: Throttle Settings.
  • Breakpoint Settings: Breakpoint Settings.
  • Reverse Proxies Settings: Reverse Proxies Settings.
  • Port Forwarding Settings: indicates Port Forwarding.
  • Windows Proxy: Logs all requests on your computer.
  • Proxy Settings: Proxy Settings.
  • SSL Proxying Settings: indicates the SSL proxy Settings.
  • Access Control Settings: Access Control Settings.
  • External Proxy Settings: External Proxy Settings.
  • Web Interface Settings: Web Interface Settings.

Recording Settings

Recording Settings Are used together with Start/Stop Recording. You can use the Recording Settings to record Charles sessions in the Start Recording state. The Recording Settings view is shown below:

Options
Include
Exclude

  • Options: Use Recording Size Limits to limit the Size of recorded data. When Charles records, the request, response header, and response body are stored in memory or written to temporary files on disk. Sometimes, the amount of data in memory may become too much, and Charles will notify you and stop recording. In this case, you should clear the Charles session to free up memory, and then start recording again. In recording Settings, you can limit the maximum size Charles will record; This won’t affect your browsing at all, Charles will just stop recording.
  • Include: Only requests that match the configured address will be recorded.
  • Exclude: Only the requests matching the configured address will not be recorded.

The Include and Exclude tabs work the same way. Select Add and fill in the Procotol, Host, and Port information that you want to monitor to filter. As shown below:

Focus
Other Host

Throttle Settings

You can Throttle Settings with Start/Stop Throttling to configure Charles network speed simulation. The Throttle Settings view is shown below:

Only for selected hosts

The options in the Throttle Settings view have the following meanings:

  • Bandwidth: Bandwidth
  • Utilistation: percentage of utilization
  • Round-trip: indicates the round-trip delay
  • MTU: byte

Breakpoint Settings

Breakpoint Settings and Enable/Disable Breakpoints. In Enable Breakpoints, Charles Breakpoint mode can be configured using Breakpoint Settings. The Breakpoint Settings view looks like this:

Add

Reverse Proxies Settings

A reverse proxy creates a Web server on a local port that transparently proxies requests to a remote Web server. All requests and responses on the reverse proxy can be logged in Charles.

Reverse proxies can be useful if your client application does not support the use of HTTP proxies, or if you want to avoid configuring it to use proxies. Create a reverse proxy for the original target Web server, and then connect the client application to the local port; The reverse proxy is transparent to the client application, allowing you to see traffic that Charles might not have had access to before.

For more information about Reverse proxy, visit Reverse Proxy

Port Forwarding Settings

Any TCP/IP or UDP Port can be configured to forward from Charles to a remote host using the Port Forwarding tool. This enables debugging of any protocol in Charles.

This is especially useful when debugging XMLSocket connections in Macromedia Flash.

You can also use Charles as a SOCKS proxy, so port forwarding is not required.

Windows Proxy(Logs all requests on your computer)

If you want to fetch requests from your computer, check the Windows Proxy option. Deselect this option if you only need to grab the phone request.

Proxy Settings

The Proxy Settings view is shown below:

Enable transparent HTTP proxying

SSL Proxy Settings

The SSL Proxy Settings view is as follows:

Enable SSL proxying
Add

Access Control Settings

Access Control Settings Indicates Access Control Settings. Access control lists determine who can use this Charles instance. Typically, you’re running Charles on your own computer, and you only intend to use it yourself, so localhost is always included in the access control list. You can also select Add, and then fill in the allowed IP address to allow an IP address to access Charles.

External Proxy Settings

External Proxy Settings External Proxy Settings. There may be a proxy server on the network that must be used to access the Internet. In this case, Charles needs to be configured to use an existing agent when attempting to access the Internet.

Separate proxy addresses and ports can be configured:

  • HTTP
  • HTTPS
  • SOCKS

If you have a SOCKS proxy, Charles will use it for all non-HTTP (S) traffic, such as port forwarding.

Web Interface Settings

Web Interface Settings Indicates Web Interface Settings. Charles has a Web interface that lets you control Charles from your browser or use external programs using the Web interface as a Web service.

In the External Proxy Settings view, select Enable the Web Interface to Enable the Web interface. You can allow anonymous access or configure a user name and password. You can also access the Web interface by accessing http://control.charles/ in a Web browser configured to use Charles as its proxy.

The Web UI provides access to the following functions:

  • Throttle control
    • Enable or disable any configured limit presets
  • The recording controls
    • Start and stop session recording
  • tool
    • Activate and deactivate tools
  • Session control
    • Clearing the current session
    • Exports the current session in any supported format
    • Download the current session in Charles’s native session format
  • Quit Charles

By examining the Web interface HTML, you can deduce how it can be used as a Web service to automate Charles.

The Tools menu

Charles is an HTTP and SOCKS proxy server, and all requests go through Charles. Here are some of the utilities provided by Charles. The view of the Tools menu is shown below:

The Tools menu contains the following functions:

  • No Caching Settings: Disables Caching Settings.
  • Block Cookies Settings: Disables the Cookie setting.
  • Map Remote Settings: Remote mapping Settings.
  • Map Local Settings: Local mapping Settings.
  • Rewrite Settings: Rewrite Settings.
  • Black List Settings: Blacklist Settings.
  • White List Settings: Whitelist Settings.
  • DNS Spoofing Settings: DNS Spoofing Settings.
  • Mirror Settings: Mirror Settings.
  • Auto Save Settings: Automatically saves the Settings.
  • Client Process Settings: Client Process Settings.
  • Compose: edit and modify.
  • D) Repeat:
  • Repeat Advanced: Advanced packet sending.
  • Validate: indicates verification.
  • Publish Gist: Publish Gist.
  • Import/Export Settings: Import/Export Settings.
  • Profiles: indicates Profiles.
  • Publish Gist Settings: Publish Gist Settings.

No Caching Settings

The No Caching tool prevents client applications, such as Web browsers, from Caching any resources. Therefore, always make a request to a remote site, and you can always see the latest version.

Scope of application

The tool can be used for each request (Enable No Caching) or Only for the requests you have configured (select Only for Selected Locations when you Enable No Caching). When applied to selected requests, simple but powerful pattern matching can be used to limit the effect of the tool to the specified host and path.

The working principle of

The No Caching tool prevents Caching by manipulating HTTP request headers that control response Caching. Remove if-modified-since and if-none-match headers from the request and add Pragma: no-cache and cache-control: no-cache. Remove Expires, last-Modified, and ETag headers from the response and add Expires: 0 and cache-Control: no-cache.

Block Cookies Settings

The Block Cookies tool prevents Cookies from being sent and received. It can be used to test a website, just as cookies are disabled in a browser. Note that web crawlers (such as Google) generally do not support cookies, so the tool can also be used to simulate views of web crawler sites.

Scope of application

The tool can be used for each request (select Enable Block Cookies) or Only for the requests you configure (select Only for Selected Locations while enabling Block Cookies). When applied to selected requests, simple but powerful pattern matching can be used to limit the effect of the tool to the specified host and path.

The working principle of

The Block Cookies tool disables Cookies by manipulating HTTP request headers that control the response to Cookies. Removes the Cookie request header from the request to prevent Cookie values from being sent from the client application, such as a Web browser, to a remote server. Removes the set-cookie request header from the response to prevent the request from setting the Cookie received by the client application from the remote server.

Map Remote Settings

The Map Remote tool changes the request site based on the configured mapping to serve the response transparently from the new site as if it were the original request.

With this mapping, you can provide all or part of a site from another site. Such as:

  • You can map xk72.com/charles/ to localhost/charlesdev/ to provide a subdirectory for xk72.com;
  • You can map all files with the specified suffix xk72.com/*.php to localhost/charlesdev/.
Use advice

Map Remote is useful if you have a development version of your site and want to be able to browse the live site through some of the requests provided by your development. For example, you might want to provide the CSS and images directories from the development server. Map to dev.com/css/ or live.com/*.css to dev.com using live.com/css/ and so on.

Mapping type
  • You can map directories to directories, such as xk72.com/charles/ to localhost/charlesdev/;
  • Files can be mapped to the file, such as xk72.com/charles/download.php mapped to abc.com/testing/test.html;
  • You can map a directory with a file pattern to a directory, such as xk72.com/charles/*.php to localhost/charlesdev/;
  • If you do not specify a path in the target map, the path part of the URL will not change. If you want to map to the root directory, specify the target path field/At the end.
HTTPS

The Map Remote tool maps HTTP requests to HTTPS targets and vice versa, so you can Map HTTP or HTTPS sites to their opposite.

Site match

Each site match may contain protocol, host, port, and path patterns to match a particular URL. Sites may include wildcards. As you add new sites to the tool, you may find more help on creating site matches.

Map Local Settings

The Map Local tool lets you use Local files as if they were part of a remote web site. You can develop files locally and test them as if they were online. The contents of the local file are returned to the client as if it were a normal remote response.

Map Local can greatly speed up development and testing that you would otherwise have to upload files to a web site to test results. With Map Local, you can test securely in your development environment.

Dynamic file

Dynamic files (such as files containing server-side scripts) are not executed by Map Local, so if there are any scripts in the file, the scripts will be returned to the browser as is, which may not be the expected result. If you want to use dynamic files as if they were part of a Remote web site, see the Map Remote tool.

The working principle of

When the request matches the Map Local Map, it checks for Local files that match the path. It does not include a query string (if any). If the requested file is found locally, it is returned as a response as if it had been loaded from a remote site, so it is transparent to the client. If the requested file is not found locally, the request is served by the web site as usual, returning data provided by the real server.

Site match

Each site match may contain protocol, host, port, and path patterns to match a particular URL. Sites may include wildcards. As you add new sites to the tool, you may find more help on creating site matches.

Rewrite Settings

The Rewrite tool allows requests and responses to be created to modify their rules as they pass through Charles. For example, add or change header information, search and replace some text in the response content, and so on.

Rewrite the set

Rewrite sets can be activated and deactivated separately. Each collection contains a list of sites and rules. These sites select the requests and responses that the rules will run.

Rewrite rules

Each rule describes a rewrite operation. Rules may affect the Header, body, or part of the REQUESTED URL; It can act on requests or responses; It can define search, replace, or just replace style overrides.

Site match

Each site match may contain protocol, host, port, and path patterns to match a particular URL. Sites may include wildcards. As you add new sites to the tool, you may find more help on creating site matches.

debugging

Rewriting tools can be difficult to debug when rewriting operations do not work as expected. If you run into problems, try adding a very basic rule, such as one with obvious header information, so that you can see if the rule matches the request exactly. Also turn on debugging in the error log to get some debugging information printed from the error log accessed from the Window menu in Charles.

Black List Settings

The Black List tool allows you to enter domain names that should be blocked. When a Web browser tries to request any page from a blacklisted domain name, the request will be blocked by Charles. You can also enter wildcards to block subdomains.

White List Settings

The Black List tool allows you to enter only permitted domain names. The Black List tool will block all requests except for whitelisted domain names.

The whitelist tool allows only specified domain names; Blacklist tool, used to block only specified domain names.

If a request matches both the Blacklist and whitelist, the request is blocked.

DNS Spoofing Settings(DNS Spoofing)

The DNS Spoofing tool allows you to trick DNS lookups by assigning your own host name to a remote address map. When a request goes through Charles, your DNS map takes precedence.

Charles contains a list of configured domain-to-IP address mappings. When a request is made for a listed domain name, the Spoof DNS plug-in finds that the spoofing IP redirects the request to that address. The host HTTP header stays the same, so just as your DNS server returns fraudulent IP.

Virtual host

A virtual host is one that has multiple sites on a single IP address, and the Web server determines the site to request based on the name typed in the browser. More precisely, it looks at the host header sent in the request.

If you don’t have DNS set up for your site, you generally can’t test it because you can’t just enter the IP address, because the server can’t get the name and therefore can’t connect the request to the site. Use DNS spoofing tools to overcome this problem.

Mirror Settings

When browsing a specific site, the Mirror tool copies the received response and saves it to the specified path on the disk.

The path to save the file will have the same directory structure as the site you browse, and Charles will create a root directory for the host name. The file name is exported from the URL and converted to the appropriate data for saving. The query string is contained in the file name. If you receive two responses from the same URL, the later file overwrites the previous file with the same name, so the response content stored in the image will always be the latest.

The selected site

The tool can be enabled for each request or just for a specific site. When used for selected sites, simple but powerful pattern matching can be used to limit the effect of the tool to a specified host and/or path.

Side effects

If the mirroring tool is enabled for the request, it will cause any compressed or encoded response to be decoded. Therefore, if the server provides a compressed response, Charles will decompress it before passing it to the client, which usually has no impact. But if you have already built your own client, or if the client expects a compressed response, this will matter. Using a Web browser has no effect.

Auto Save Settings

The Auto Save tool automatically saves and clears recorded sessions at a set interval.

This is useful if you have Charles monitoring network activity for long periods of time and want to break down the records into manageable units, or avoid out-of-memory situations that can occur due to large amounts of data.

Enter the save interval in minutes and the directory to save the session file. You can choose whether to start the Auto Save tool every time you run Charles, otherwise the Auto Save tool will always be disabled when Charles starts.

Time stamps are stored in the name of the session file in the yyyyMMddHHmm format so that they appear in the correct order when sorted alphabetically.

Client Process Settings

The Client Process tool displays the name of the local Client Process responsible for issuing each request. The client process is usually your Web browser (such as Firefox.exe), but the client process tool can help you discover many HTTP clients that you may not know.

The client process name is displayed in the Notes area of each request.

Client process tools are useful if you can see requests in Charles that are not identified with the original process. It only works with requests made on the computer running Charles.

The tool introduces a short delay before Charles accepts each connection. Delays are usually not noticeable or significant.

The selected site

The tool can be enabled for each request or just for a specific site. When used for selected sites, simple but powerful pattern matching can be used to limit the effect of the tool to a specified host and/or path.

Compose(edit edit)

The Compose tool allows for modifications to the original request.

Repeat (Repeat)

The Repeat tool allows you to select a request and Repeat it. Charles resends the request to the server and displays the response as a new request. This is useful if you are making back-end changes and want to test them with repeated requests in your browser (or other client). Especially if it takes some effort to recreate the request, such as getting points in the game, this can save a lot of effort.

Repeated requests are done internally in Charles, so the response cannot be viewed in a browser or other client; the response can only be viewed in Charles.

Repeat Advanced

The Repeat Advanced tool extends the Repeat tool with options for the number of iterations and concurrency. This is useful for load testing.

Validate (validation)

The Validate tool allows Charles to Validate recorded responses by sending them to the W3C HTML validator, W3C CSS validator, and W3C Feed validator.

The validation report is displayed in Charles and contains any warnings or errors associated with the corresponding line in the response source (double-click the line number in the error message to switch to the source view).

Because Charles tests the responses it records, it can test scenarios that are not easily tested, such as rendering an error message after submitting a form.

revalidation

After validation, you can select the response from the validation results and Repeat, Repeat the original request, and then re-validate the results.

Publish Gist

The Publish Gist tool can Publish selected requests and responses as bullet points. By default, this bullet point will be posted anonymously, which means you won’t be able to delete it. You can authorize Charles to Publish using your GitHub account in the Publish Gist Settings of the Tools menu.

Import/Export Settings

The Import/Export tool allows you to Import/Export Charles’ Proxy, Tools, Preferences, and so on.

Profiles (configuration)

Profiles contains a full copy of all configuration Settings.

Each time you change the current Settings, the system updates the current active profile, and when you change the active profile, all Settings are restored to the state they were when you last used the profile.

Note that if you import a saved configuration, the Settings of the current configuration file will be overwritten. It is recommended to use import/export to back up or create snapshots of the current configuration and configuration files to maintain multiple parallel workspaces.

Charles Tutorial

Use Charles to capture packets on the PC

Charles automatically configures the proxy Settings for the browser and tool, so opening the tool will automatically capture packets. Just make sure there are a few things:

  1. Make sure Charles is in Start Recording state.
  2. Check the Proxy | Windows Proxy and the Proxy | Mozilla FireFox Proxy.

Use Charles to capture packets on the mobile end

The principle of mobile phone packet capture is similar to that of PC. The mobile phone entrusts the network to Charles for proxy to communicate with the server. The specific steps are as follows:

  1. Keep your phone and computer on the same LAN, not necessarily on the same IP segment, but on the same router.

  2. PC configuration:

    • Turn off the firewall on your computer (this is important).
    • Turn on Charles’s proxy function: Open via main course singlesProxy | Proxy SettingsPop up and fill in the proxy port (the default port is8888, do not modify), checkEnable transparent HTTP proxying.
    • If you don’t need to grab the request on the computer, you can uncheck the Proxy | Windows Proxy and the Proxy | Mozilla FireFox Proxy.
  3. Mobile terminal configuration:

    • Via Charles’ main menuHelp | Local IP AddressOr use a command line toolipconfigView the IP address of the local host.
    • Set proxy: Turn on the WIFI proxy Settings on the phone, enter the PC IP and Charles proxy port.
  4. After setting up, we open any application that requires network request on the phone, and we can see Charles pop up the confirmation menu for requesting connection on the phone (only for the first time). Click Allow to complete the setting.

  5. After completing the above steps, you can capture packets.

HTTPS packet capture using Charles

You need to configure HTTPS packet capture based on HTTP packet capture. The following steps need to be completed:

  1. The HTTP packet capture configuration is complete.
  2. PC installation, Charles Certificate: by Charles main menu Help | SSL Proxying | Install Charles Root Certificate to Install the Certificate.
  3. Setting up the SSL proxy: Open the SSL proxy through the main courseProxy | SSL Proxy SettingsPopover, check itEnable SSL proxying.
  4. Install the Charles certificate on the mobile terminal: By Charles main menu Help | SSL Proxying | Install Charles Root Certificate on a Mobile Device or Remote Browser installed Certificate.
  5. After setting up, we open any application that requires network request on the phone, and we can see Charles pop up the confirmation menu for requesting connection on the phone (only for the first time). Click Allow to complete the setting.
  6. After completing the preceding steps, you can capture packets using HTTPS.

Charles License

  • Registered Name: https://zhile.io
  • License Key: 48891cf209c6d32bf4

The registration code is from the network. The registration code is applicable to Windows and Mac.

Thank you

  • Charles Documentation