在Linux上抓HTTPs/TLS流量包
介绍
- 参考 SSL/TLS 概览
- 有两种方法抓包:
- 客户端使用浏览器获取对称加密的密钥
- 使用 SSL 私钥证书,需满足
- 加密算法不能使用
DHE
、ECDHE
- 报文须完整,包括TCP握手信息
获取对称加密的密钥方法
安装 wireshark
sudo add-apt-repository universe
# sudo add-apt-repository ppa:wireshark-dev/stable
sudo apt install wireshark
# 配置
sudo dpkg-reconfigure wireshark-common
配置环境变量
# /etc/profile
export SSLKEYLOGFILE=/tmp/sslkeylog.txt
需要重启 Linux 机器
抓包
- 打开 wireshark,配置:
编辑
> 首选项/Preferences
> Protocols
> SSL/TLS
> (Pre)-Master-Secret log filename
为 SSLKEYLOGFILE
的路径
- 使用浏览器打开网页,浏览 https 的页面,即可抓取解密的包
证书方式
- wireshark 直接抓包
编辑
> 首选项/Preferences
> Protocols
> SSL/TLS
> 导入RSA Key
和密码(若存在) > 抓包
- tcpdump 抓包
- 抓包
tcpdump -i eth0 tcp and port 443 -s0 -nn -w first.cap
- wireshark 指定
SSLKEYLOGFILE
解绑