美文网首页
Wireshark解密http/2包

Wireshark解密http/2包

作者: rogerxfederer | 来源:发表于2017-07-20 14:35 被阅读0次

本文用于wireshark解密web浏览器访问http/2网站

Chrome自带分析http/2功能

在Chrome浏览器地址输入chrome://net-internals/#http2进入即可,会显示当前活跃的http/2 session,点击具体session ID,就可以查看具体frame交互信息,访问google http/2 session:

image.png

Wireshark分析http/2

wireshark能从网络协议栈底层分析网络包,2.0以上最新版本开始支持http/2,可以从这个地址下载安装包:

https://www.wireshark.org/#download

目前主流浏览器都只会支持http/2 over tls, wireshark直接抓包都是加密的无法查看,但目前chrome和firefox支持把tts加密的对称秘钥保存到文件中,具体格式:NSS Key Log Format,目前只有系统环境变量中存在SSLKEYLOGFILE路径才会生成文件(经测试出于安全的原因环境变量SSLKEYLOGFILE 设置不起作用, 当前使用FireFox 54.0.1 64 位)。

Mac环境操作步骤:
a. 进入终端创建sslkeylog.log
touch ~/tls/sslkeylog.log

b.设置环境变量

echo "export SSLKEYLOGFILE=~/tls/sslkeylog.log" >> ~/.bash_profile && . ~/.bash_profile 

c.wireshark配置logfile path
操作路径 Edit→Preferences→Protocols→SSL→(Pre)-Master-Secret


image.png

d. 打开Wireshark和Firefox

open /Applications/Wireshark.app(非强制)
open /Applications/Firefox.app --args -sslkey-log-file=/Users/wuruisheng/tls/sslkeylog.log (需要传入log-file path,坑)

e. 开始抓包分析

  1. 设置Wireshark开始进行抓包


    image.png
  2. Firefox 访问https://www.google.com.hk/webhp?hl=zh-CN&sourceid=cnhp&gws_rd=ssl
    sslkeylog.log会有写入CLIENT_RANDOM,表示成功

    image.png

“解码”上下文菜单弹出窗口,点击“确认”(非常重要)


image.png

http/2协议栈:


a

相关文章

网友评论

      本文标题:Wireshark解密http/2包

      本文链接:https://www.haomeiwen.com/subject/qtwdkxtx.html