How to use Fiddler to capture packets on the mobile terminal? With a video tutorial package you learn

Table of contents

foreword

grab bag

What is packet capture

In which scenarios do you need to capture packets?

Fiddler

Fiddler capture principle

Install

Fiddler mobile terminal capture

Step One: Allow Remote Computers to Connect

The second step is to set up the mobile phone network proxy

The third step, allow to capture HTTPS connection

The fourth step is to install the certificate on the mobile phone


foreword

In this article, the blogger wants to use easy-to-understand words to let everyone understand the following:

  1. What is packet capture
  2. Which scenarios need to use packet capture
  3. The principle of Fiddler packet capture
  4. How to use Fiddler to capture packets on the mobile side

grab bag

Packet (Packet) is the data unit in the communication transmission of TCP/IP protocol, generally also called "data packet".

The data packet we usually refer to in the test process is actually the data requested by the interface. In the HTTP request, it includes request header information, request content, response header information, and response content.

What is packet capture

Use specific tools to capture the data packets sent and returned between the client and the server. The purpose is to analyze the protocol and content of the data packet, so as to judge whether the design of the interface meets the requirements, such as capturing the request parameters and response parameters of a request to check whether the parameters are correct.

Fiddler packet capture video tutorial: The whole network packet capture ceiling tutorial, the most detailed Fiddler/Charles packet capture teaching video taught by station B. 2 hours package you learn_哔哩哔哩_bilibili icon-default.png?t=N4P3https://www.bilibili.com/video/BV1tv4y1575S/?spm_id_from=333.999.0.0                   

 

In which scenarios do you need to capture packets?

For beginners or students who have not been exposed to interface testing, they may not understand why it is necessary to learn to capture interface data when doing interface testing or interface automation testing.

So in which scenarios do you need to capture packets to obtain request data?

  1. To reproduce the bug, when it is necessary to intercept the data to locate the problem;

  2. When judging whether the problem is a front-end bug or a back-end bug;

  3. When doing interface testing, but the development does not provide interface documents, it is necessary to capture packets to obtain interface information;

  4. When we don’t know which interfaces are called in a certain functional scenario or certain functional scenarios, or when we don’t know the sequence of interface calls;

  5. When the return parameter needs to be modified (for mock or other scenarios)

In the actual test process, the most used scenarios are 1, 2, 3, and 4.

Fiddler

There are many kinds of packet capture tools, such as Wireshark, Fiddler, Charlse, Tcpdump, browser tools (F12), etc., but in software testing, the packet capture objects are generally HTTP protocol interfaces, so the most common ones are browser tools, Fiddler/Charlse .

The features of Fiddler are simply summarized as follows:

  1. Fiddler can capture HTTP/HTTPS requests between the client and the server, set breakpoints on interface requests, and even modify input and output data

  2. Fiddler can only grab the HTTP/HTTPS protocol

  3. In addition to capturing packets on PC-side browsers, Fiddler also supports capturing packets on mobile terminals

Fiddler capture principle

Usually, we use a browser to browse the web, or use an APP on a mobile phone, and the interaction can be represented by the following simplified flow chart:

The client (PC or mobile) sends HTTP requests to the server for data interaction, and our requirement is to capture the data during this interaction.

We only need to add an intermediary between the client and the server, so that the data exchanged between them all pass through this intermediary, and the intermediary records the data that passes through itself, so that the specific interaction between the client and the server can be obtained data.

Fiddlercan act as this intermediary role, and the interaction process is as follows:

Starting Fiddleris actually starting a proxy web server (Proxy), the proxy address is 127.0.0.1, and the port is 8888. As long as the HTTP request 127.0.0.1:8888 is sent and received through the proxy (that is, Fiddler), Fiddler will record the HTTP request data passing through itself, and then capture the relevant data of the HTTP request.

And how can we make HTTP requests pass through 127.0.0.1:8888the proxy? When Fiddler starts, the proxy of the IE browser will be automatically set 127.0.0.1:8888as the proxy address. Chrome and Firefox need to be manually modified in the browser, and the mobile terminal needs to be set in the mobile phone.

Install

Enter the official website to download,

The content to be filled can be filled in as follows. For Windows system, click [Download for Windows]. After clicking, it will jump to the page and start downloading (if there is no download, you can try twice more). If there is no download, click according to the prompts on the jumping page.

After downloading, get the installation file FiddlerSetup.exe, and install it all the way for fools. The currently downloaded version is Progress Telerik Fiddler Classic.

After the installation is complete, open Fiddler, the main interface is as follows:

  • As shown in the figure, switch to Inspectors to view the request parameters and return parameters of the corresponding request

  • To display different content and formats of request parameters and return parameters, you can switch the Tab button at the top of the corresponding display window in the figure, such as Headers, WebForms, Raw, Json, etc.

  • For the description of the session window icon, see the description at the end of the article.

Next, I will introduce how to use Fiddler to capture packets on the mobile phone.

fiddler capture package:

The whole network packet capture ceiling tutorial, the most detailed Fiddler/Charles packet capture teaching video taught by station B. 2 hours package you learn_哔哩哔哩_bilibili icon-default.png?t=N4P3https://www.bilibili.com/video/BV1tv4y1575S/?spm_id_from=333.999.0.0

 

Fiddler mobile terminal capture

Let's first repeat the general idea of ​​capturing packets on the mobile terminal:

  1. Fiddler needs to be set to allow remote computer connections, that is, to allow mobile phones to capture packets;

  2. Set the mobile phone proxy network proxy, so that the mobile phone sends HTTP requests through the Fiddler proxy (that is, Fiddler acts as an intermediary for data transmission and reception);

  3. https request packet capture settings (if you only capture http requests, the above two steps are enough, but in actual work, it is often necessary to capture https request data).

According to the above ideas, we start to make specific settings.

Step One: Allow Remote Computers to Connect

Setting steps: Tools-->Options-->Connections-->check Allow remote computers to connect-->click OK, other defaults are fine, as shown in the figure below:

After checking, if there is a pop-up confirmation page, click [OK]. 8888By the way, the default port number in the page above is the default port number, which needs to be used in the second step of setting.

The second step is to set up the mobile phone network proxy

First of all , you need to obtain IPv4the address of the computer where Fiddler is installed, and enter it in cmd ipconfig, as shown in the following figure:

Then , find the corresponding WLANnetwork on the mobile phone, and set the network proxy. Taking the Honor V20 mobile phone as an example, the operation steps are shown in the figure below:

Mobile phone system settings-->WLAN-->Modify Network-->Advanced Options-->Proxy-->Choose Manual-->Enter the host name in the previous step IPv4-->Enter the port in the default 8888-->Save

Notice:

  • The mobile phone must be connected to the same network as the computer , that is, a WIFI or a hotspot directly connected to the computer with the mobile phone, and then configure the proxy settings for this network, otherwise the data cannot be captured.

  • Step 2 When you choose to modify the network, different mobile phone models may require different operations to enter the modify network page.

At this point, after restarting Fiddler, you can capture the http request on the phone. If you can't grab it, you can save the proxy settings in the above picture again in your phone, and then make a request. After reaching this step, open the APP operation on the mobile phone, and capture the http request of the packet, as shown in the following figure:

It can be seen that only http requests are captured here. If you want to capture https requests, you need to perform the following operations .

The third step, allow to capture HTTPS connection

Setting steps: Tools-->Options-->HTTPS-->check Decrypt HTTPS traffic-->check Ignore server certificate errors-->click OK

Note that you need to restart Fiddler after saving the settings to take effect .

The fourth step is to install the certificate on the mobile phone

Proceed as follows:

  1. Select any browser on the mobile phone, enter the proxy address set in the second step, host is the IPv4 address of the computer where Fiddler is installed, and the port number is the default 8888
  2. Click Download Certificate on 1the opened webpageFiddlerRoot certificate

This step is enough for Android mobile phones. Apple mobile phones still need to trust the downloaded certificate in the mobile phone settings. The operation steps of trusting the certificate will not be explained here.

After completing these two steps, we can capture both the http requests sent by the mobile phone and the https requests sent by the mobile phone. Open the Toutiao APP on your mobile phone and verify as follows:

At this point, the Fiddler mobile terminal packet capture setting is complete.

Attach the description of the session window icon, as follows:

Fiddler packet capture: The whole network packet capture ceiling tutorial, the most detailed Fiddler/Charles packet capture teaching video taught by station B. 2 hours package you learn_哔哩哔哩_bilibili icon-default.png?t=N4P3https://www.bilibili.com/video/BV1tv4y1575S/?spm_id_from=333.999.0.0

 

 

Guess you like

Origin blog.csdn.net/MXB1220/article/details/130968203