preface
In use beforewireshark
When we do protocol analysis, we always think that it can only grasp HTTP packets, so we always use it when we grasp HTTPS packetsFiddler
One day, however, I suddenly wanted to grab itHTTP2
Take a look at your message,Fiddler
I couldn’t, so I found out after Googlewireshark
It can be supported, only under specific conditions.
Problems of fiddler
Fiddler
Not yetHTTP2
Agreement, can’t see the realHTTP2
Some people here may have doubts and say that I will use it clearlyFiddler
Got itHTTP2
Protocol message, that’s becauseFiddler
Man in the middle attacks the server and demotes the protocol toHTTP1
Agreement, so what we actually see is the sameHTTP1
The message can be intuitively felt through the following two pictures:
- Direct access to services supporting http2 without proxy
- Through proxy access, packet capture
As you can see, when capturing packets through the agent, the protocol becomeshttp/1.1
。
Grabbing with Wireshark
Now the mainstream browsers on the market are all based on http2TLS
That is to say, we need to analyzeHTTP2
We have to go through it firstTLS
This pass, otherwise can only analyze a pile of encrypted garbled code.
wireshark
Support two ways to decryptSSL/TLS
Message:
- Through the private key of the website
- TLS symmetric encryption is stored in the external file for Wireshark encryption and decryption through the browser
Next, I’ll demonstrate them one by one
1. Through the private key of the website
If the website you want to capture is your own, you can use this method, because it needs to use the private key used by the website to generate the certificate for decryption, which is configured on nginxssl_certificate_key
Add the corresponding private key file to the Wireshark configuration
And then throughwireshark
You can see the clear text:
As you can see from the picture above, I passedcurl
After configuring the corresponding private key of the server, you can grab the corresponding HTTP plaintext.
However, the disadvantages are also very obvious. We can only analyze the websites with our own private key. If others’ websites can’t be analyzed, fortunately, there is a second scheme to support.
2. Through SSL log function of browser
At present, the scheme only supportsChrome
andFirefox
Browser, by settingSSLKEYLOGFILE
Environment variables, you can specify the browser in the accessSSL/TLS
The corresponding key is saved to the local file when the website is opened. After having this log filewireshake
The message can be decrypted.
-
Set up first
SSLKEYLOGFILE
Environment variables:Note: This is operated on Windows system, the same as other operating systems
- to configure
wireshake
, Preferences > protocls > TLS:Configure the file path specified in the first step
-
Restart the browser to capture packets:
Similarly, HTTP plaintext can be captured.
Note: remember to delete environment variables when not capturing packages, so as to avoid performance waste and security problems
The advantage of scheme 2 is very obvious, which can capture the information of any websiteSSL/TLS
The only disadvantage of encrypted message is that it can only be supported by the browser. Scheme 1 can capture packets for any HTTP client.
Capturing http2 message through wireshake
It’s all aboutTLS+HTTP1
Carry on the grab bag, the mainstream browser on the marketHTTP2
It’s all based onTLS
So it’s the sameTLS
This layer decrypts the original plaintext.
Here is an analysishttps://www.qq.com
For example, why not classichtts://www.baidu.com
Because Baidu home page is stillHTTP/1.1
agreement.
- Use the second scheme above to configure
wiresharke
- adopt
http2
Keyword filtering - Browser access
https://www.qq.com
- see
HTTP2
Message:That’s it
HTTP2
Now, http2 protocol is very complex, and I’m still in the learning stage, so I won’t say much here.
Postscript
Wireshake is really a very powerful network analysis toolHTTPS
andHTTP2
When it is becoming the mainstream, it can be used to help us deepen our understanding of these agreements, so as to meet new opportunities and challenges.
reference resources
The author of this paper: MonkeyWie
Link to this article: https://monkeywie.github.io/2020/08/07/wireshark-capture-https/
Copyright notice:Except for special announcement, all articles in this blog adoptBY-NC-SALicense agreement. Reprint please indicate the source!