HTTP protocol format
The HTTP protocol is a very widely used application layer protocol. When we enter a URL ("website address") in the browser, the browser will send an HTTP request to the client. After the server receives the request, it will return An HTTP response.
In order to be able to see the details of HTTP requests and responses, we need to use a packet capture tool. This article uses Fiddler as an example.
http working process
When we send a request in the browser, the http protocol will be used at this time. In fact, what we send is an http request, and the server will also return an http response to us.
Here we send a request, and there may be many interactions between http requests and responses.
In the process of HTTP protocol interacting through the network, we learned some keywords.
Client: the party that sends the request (we are the client when we query events in the browser)
Server: The party that returns the response (after we send a request to Baidu, Baidu will return a response to us, and Baidu can be understood as the server)
Request: Data sent by the client to the server.
Response: Server to client.
The principle of packet capture tool
The Fiddler packet capture tool is equivalent to a "proxy program": when the client sends an HTTP request to the server, the client will first hand the request to Fiddler, and Fiddler will then transfer the request to the server; when the server returns an HTTP response, it will first The response is given to Fiddler, and Fiddler then gives the response to the client.
Therefore, Fiddler will know the details of the data exchanged between the client and the server.
A simple understanding is that Fiddler is equivalent to a little brother who runs errands for the client~
There are two types of agents:
Forward proxy: An agent program that provides services to clients. At this time, forward proxy is equivalent to hiding the real client. The server does not know who the real client is.
Reverse proxy: A proxy program that provides services to the server. At this time, the reverse proxy is equivalent to hiding the real server. The client does not know who the real server is.
Use fiddler to capture packets
Fiddler tool page introduction
List of caught packages
On the left side of fiddler is a list of captured packets. The contents of the list are constantly changing. This is normal, because as long as your computer interacts with the network, it will capture HTTP packets.
Package details
Double-click a package on the left to enter the package details page.
The upper right side is the http request message.
The bottom right is the http response message.
Package details
raw is translated as native, which is the most original request data of http.
Clicking view in notepad in the lower right corner will open the data in the form of notepad, so you can see the data more clearly.
Locate the package you need
After we capture the packet, how do we quickly locate the packet we sent?
The black packet represents ordinary data; the blue packet response is html.
Look at the domain name, position according to the domain name, like Baidu, Baidu, you will know
Look at the data length of the response, generally look for the longer one.
Packet capture data analysis
http request
First line
GET https://mbd.baidu.com/newspage/api/getpcvoicelist?callback=JSONP_0& HTTP/1.1
Request header header
Starting from the end of the first line to the end of the blank line, the blank line is the end mark of the header.
text
After the header ends, the following content is the main text, sometimes there is no main text.
http response
First line
HTTP/1.1 200 OK
Response header
Starting from the end of the first line to the end of the blank line, the blank line is the end mark of the header.
text
The content after the blank line.
Generally speaking, when surfing the Internet, the content displayed on the page, even a simple page, is the result returned by the server as a response.
This is the use of fiddler packet capture tool in Android reverse development to capture packets. To learn more about reverse development, you can refer to the "Android Reverse Documentation" and click to view the detailed categories.
Finally: download the packet capture tool fiddler
There are many packet capture tools. We mainly study http here, so we simply download an http packet capture tool.
- Enter fiddler official website
Just search for fiddler directly in the browser, remember to enter the official website.
How to identify the official website? There will be an official website displayed in the lower right corner, such as fiddler, and things related to fiddler will be displayed on the page.
- Click to download the classic version
The classic version is a free version, there is this one
- Fill in the relevant information to download