zoukankan      html  css  js  c++  java
  • [https][tls] 如何使用wireshark查看tls/https加密消息--使用私钥

    之前总结了使用keylog进行https流量分析的方法:

    [https][tls] 如何使用wireshark查看tls/https加密消息--使用keylog

    今天总结一下使用服务器端证书私钥进行https加密信息解密的方法,如下:

    一 server端

    首先我有一个在4040端口开启了https服务的nginx server。使用如下证书与服务配置

    ╰─>$ ll ~/Keys/https/sni/ |grep test2
    -rw-r--r-- 1 tong tong 1.4K Sep 24 17:50 sni_test2.cer
    -rw------- 1 tong tong 1.7K Sep 24 15:37 sni_test2.key

    二 client 端

    服务启用后,在client端,分别使用DHE与AES算法进行秘钥协商通信,如下:

    curl --cacert ~/Keys/https/root/root.cer  https://test2.www.local:4040 -v
    * SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
    ... ...
    
    curl -k --cacert ~/Keys/https/root/root.cer --ciphers AES128-GCM-SHA256 https://test2.www.local:4040 -v
    * SSL connection using TLSv1.2 / AES128-GCM-SHA256
    ... ...

    curl的算法支持列表,见如下链接的openssl小节

    https://curl.haxx.se/docs/ssl-ciphers.html

    使用tcpdump抓取以上两侧通信的pcap包

    -rw-r--r-- 1 root root 4.4K Oct 29 14:49 4040-aes128.pcap
    -rw-r--r-- 1 root root 4.5K Oct 29 14:37 4040-dhe.pcap

    三 wireshark

    DHE协商算法,是不能被该方法解析的,只能使用keylog方式。任何一次一密的通信方式(完美前向加密)都不能使用该方法解析。

    接下来,只分析aes128的数据包。

    使用wireshark打开

    在 edit->Preferences->Protocols->TLS->RSA keys list 中进行编辑,并将上文中提到的私钥sni_test2.key配置其中。如图:

    之后,保存配置。可以看到加密的tls流量已经被成功解析了。

    注意:

    需要注意的是,key文件的格式,以及是否有密码。我的是没有密码的,格式如下:

    ╰─>$ file ~/Keys/https/sni/sni_test2.key 
    /home/tong/Keys/https/sni/sni_test2.key: PEM RSA private key

    根据以前的经验,有密码的key可能会有一下问题。https://www.cnblogs.com/hugetong/p/6845436.html

  • 相关阅读:
    python 3字符编码
    python 数据类型 datatype
    部署python django程序
    linux centos7安装python3
    关于mysql数据库优化
    关于bottle WEB框架中签名cookie的一点理解
    1111
    bottle框架剖析
    the difference __str__ and __repr__
    property getitem setitem
  • 原文地址:https://www.cnblogs.com/hugetong/p/11759010.html
Copyright © 2011-2022 走看看