如何使用Wireshark解密RDP协议

问题场景

由于RDP默认是启用TLS加密的,因此,如果我们想要深入分析RDP协议通讯流量,需要对其进行解密。

实验环境

  • Kali linux虚拟机 (RDP客户端)
  • Win 7 虚拟机 (RDP服务端)

解决方案

导出Mimikatz私钥证书

我们可以使用Mimikatz导出RDP协议的私钥证书

图片[1]-如何使用Wireshark解密RDP协议-FancyPig's blog

下载后,我们进行解压,我们要使用的是x64目录下的mimikatz.exe

首先打开x64

图片[2]-如何使用Wireshark解密RDP协议-FancyPig's blog

我们以管理员身份运行mimikatz.exe

图片[3]-如何使用Wireshark解密RDP协议-FancyPig's blog
privilege::debug
crypto::capi
crypto::certificates -systemstore:CERT_SYSTEM_STORE_LOCAL_MACHINE -store:"Remote Desktop" /export
图片[4]-如何使用Wireshark解密RDP协议-FancyPig's blog

这里可以看到已经成功导出

图片[5]-如何使用Wireshark解密RDP协议-FancyPig's blog

将证书pfx文件转换为

你如果想在windows电脑上使用,可以在上面的链接下载对应版本

图片[6]-如何使用Wireshark解密RDP协议-FancyPig's blog

可以直接下载exe的文件,你需要使用cmd进入到下载的路径

openssl.exe pkcs12 -in server_certificate.pfx -nocerts -out server_key.pem -nodes

当然,也可以直接使用kali linux里自带的

openssl pkcs12 -in server_certificate.pfx -nocerts -out server_key.pem -nodes
图片[7]-如何使用Wireshark解密RDP协议-FancyPig's blog

输入密码mimikatz

然后我们发现成功输出了server_key.pem文件

图片[8]-如何使用Wireshark解密RDP协议-FancyPig's blog

Wireshark抓包

我们此时打开Wireshark进行抓包,并登录RDP

fancypigsec是win 7虚拟机的登录用户名,我们这里没有密码,则可以直接登录

rdesktop 192.168.244.138 -u fancypigsec
图片[9]-如何使用Wireshark解密RDP协议-FancyPig's blog

无密码登录的问题,我们之前教程里已经进行了讲解,这里不再赘述

Wireshark配置RSA私钥

我们使用Wireshark打开刚刚抓好的pcap包

这里是没有进行解密的,只有四行

图片[10]-如何使用Wireshark解密RDP协议-FancyPig's blog

我们点击左上角的编辑>首选项

图片[11]-如何使用Wireshark解密RDP协议-FancyPig's blog

选择Protocols>TLS>RSA

如果你懒得往下翻,可以敲击TL

图片[12]-如何使用Wireshark解密RDP协议-FancyPig's blog

点击RSA Keys list后面的Edit···

图片[13]-如何使用Wireshark解密RDP协议-FancyPig's blog

点击+

图片[14]-如何使用Wireshark解密RDP协议-FancyPig's blog

在key File这里选择我们刚才的pem文件

图片[15]-如何使用Wireshark解密RDP协议-FancyPig's blog
图片[16]-如何使用Wireshark解密RDP协议-FancyPig's blog

然后我们还需要配置服务器IP、端口、协议

  • IP是windows 7虚拟机的IP地址 192.168.244.137
  • 端口号是3389
  • 协议是tpkt

配置完成后点击ok

图片[17]-如何使用Wireshark解密RDP协议-FancyPig's blog

然后我们需要重启wireshark,重新打开

发现完整的协议相关内容已经可以读取了

图片[18]-如何使用Wireshark解密RDP协议-FancyPig's blog

常见问题

如果遇到下面的报错,这里建议大家使用Win7虚拟机,Win10的貌似会出现这样的问题

ERROR kuhl_m_crypto_l_certificates ; CertOpenStore (0x00000002)
图片[19]-如何使用Wireshark解密RDP协议-FancyPig's blog

这里应该是没有启动RDP协议,启动之后就不会有上述报错了

开启RDP协议后,出现下面的报错

ERROR kuhl_m_crypto_l_certificates ; CryptAcquireCertificatePrivateKey (0x80090016)
        Public export  : OK - 'CERT_SYSTEM_STORE_LOCAL_MACHINE_Remote Desktop_0_DESKTOP-1JQI986.der'
        Private export : ERROR kull_m_crypto_exportPfx ; PFXExportCertStoreEx/kull_m_file_writeData (0x80090016)
图片[20]-如何使用Wireshark解密RDP协议-FancyPig's blog

der公共证书可以正常导出,私钥证书貌似无法导出,下面的一些issues里也有讨论,大家可以参考下呢

相关issues参考

  • https://github.com/gentilkiwi/mimikatz/issues/325
  • https://superuser.com/questions/1635710/why-am-i-getting-this-error-when-attempting-to-export-a-private-key-with-mimikat

© 版权声明
THE END
喜欢就支持一下吧
点赞9赞赏 分享
评论 共4条

请登录后发表评论