Packets transmitted using the SSL/TLS protocol are encrypted after the handshake, making their content inaccessible even when captured with Wireshark. This article introduces a method to decrypt TLS packets into plaintext.

使用 SSL/TLS 協議傳輸的封包在 handshake 之後以加密形式傳輸,即使wireshark 抓包也無法看到內容,
本文介紹使TLS 封包解為明文的方法

Version info
windows OSMicrosoft Windows 7
wireshark Version3.4.9 (v3.4.9-0-g365e236f5efe)
vlcv3.0.8
google chrome版本 95.0.4638.54 (正式版本) (64 位元)

Decrypt Steps

Run wireshark to capture

Under normal circumstances, the protocol will be displayed as TLS v (in the image, it shows TLS v1.2) Application Data. This appears after the Certificate, Server (Client) Key Exchange. The content is in an encrypted state.

原本的情況是會顯示 protocol 為 TLS v<TLS 的版本> (圖中是 TLS v1.2) Applicaiton Data
出現在 certificated, Server (client) Key exchange 之後
內文處於加密的狀態
在这里插入图片描述

Add env variables

Add an environment variable SSLKEYLOGFILE with the value set to a new file. Then, restart the browser or other target HTTPS clients (e.g., VLC Player, etc.).

新增一個環境變數 SSLKEYLOGFILE,數值是一個全新的檔案
然後 重啟瀏覽器,或是其他目標 https clients (VLC Player etc)

在这里插入图片描述
After starting the stream, this file will be created, and it will contain content similar to the following.
開始串流之後這個檔案會被創建且出現類似如下內文

在这里插入图片描述

Add SSLKEYLOGFILE to wireshark

Edit -> Preference -> Protocol -> TLS
Add (pre)-master-secret log filename

在这里插入图片描述

Decrypted TCP

After completing the previous step, start capturing packets again. In the packets following the Change Cipher Spec Finished (completion of the TLS handshake), you will see info [TLS segment of a reassembled PDU], which indicates the encrypted TCP content. By clicking on it, you will see ‘Decrypted TLS,’ containing the decrypted plaintext.
完成上一步之後重新開始抓包,在 Change Cipher spec Finished (TLS 握手完成)以後的包, info [TLS segment of a reassembled PDU] 這就是被加密的 tcp 內容,點開以後會出現 Decrypted TLS 裡面是解密的明文
在这里插入图片描述

Save printable text file

Save in wireshark

File -> export packet deceptions -> As Plain text
select as:
在这里插入图片描述

View the saved decrypted content 查看保存下來的內文

It will display the package number and other protocol details
會顯示package number 等協議內容

在这里插入图片描述

在这里插入图片描述

Reference

https://www.youtube.com/watch?v=5qecyZHL-GU&ab_channel=ChrisGreer

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐