使用 openssl 命令行工具解密 SSL 流量 7

使用 openssl 命令行工具解密 SSL 流量 7

生成主密钥/密钥时,我遵循了 shell 脚本中概述的步骤。我通过多次手动输入这些步骤(手动输入 $key)来验证我是否正确地将数据传递给它,最终我在这种情况下得到了相同的结果/数据

密钥 = 上一步解密的预主密钥

03033ab0d673caefc4a9f6d35cf51d349815d67a09ac454f11dfb9741c96001a
66a3e82f688b82138403018384cf35f2

mseed.key = "master secret" + client.random + server.random 当我使用 hexdump xxd -p mseed.key 时,该文件是一个二进制文件,因此您可以看到数据:

6d617374657220736563726574 5b689404b500456eef2f1a79ec782eb3ee
aac3a8d7c02ae03c8426f363b18a33 5b6894043bb1289e158b0278ef66dc
53c9fa71e75e900739af2657cd4476ec1e

Note: the spaces are not in the data I added those manually to make it clear

客户端.随机xxd -p crnd.bin

5b689404b500456eef2f1a79ec782eb3eeaac3a8d7c02ae03c8426f363b1
8a33

server.random xxd-srnd.bin

5b6894043bb1289e158b0278ef66dc53c9fa71e75e900739af2657cd4476
ec1e

只是为了清楚这些随机数也包括 unix 时间前缀(正确吗?)

key=${1} #passed to shell script 
openssl dgst -sha256 -mac hmac -macopt hexkey:$key <mseed.key -binary >a1
openssl dgst -sha256 -mac hmac -macopt hexkey:$key <a1 -binary >a2
openssl dgst -sha256 -mac hmac -macopt hexkey:$key <a2 -binary >a3
openssl dgst -sha256 -mac hmac -macopt hexkey:$key <a3 -binary >a4

下一步是:

cat a1 mseed.key | openssl dgst -sha256 -mac hmac -macopt hexkey:$key -binary >k1
cat a2 mseed.key | openssl dgst -sha256 -mac hmac -macopt hexkey:$key -binary >k2
cat a3 mseed.key | openssl dgst -sha256 -mac hmac -macopt hexkey:$key -binary >k3   
cat a4 mseed.key | openssl dgst -sha256 -mac hmac -macopt hexkey:$key -binary >k4

接下来提取主密钥

cat k1 k2 | head -c48 | xxd -p -c48 > master_secret.hex
truncate -s-1 master_secret.hex

此时 master_secret

$cat master_secret.hex
ee45b637f95ddf3b3bf51661cdf4e07bdd63a67f2d2df776322992b3fd871fe4ba38debcd7179bf4
ef8b8bb814fe4544d

我从 wireshark 日志中提取了对话过程中的客户端随机数据,并将其保存为二进制文件 crnd.bin

Random: 5b689404b500456eef2f1a79ec782eb3eeaac3a8d7c02ae0...
    GMT Unix Time: Aug  6, 2018 14:31:32.000000000 Eastern Daylight Time
    Random Bytes: b500456eef2f1a79ec782eb3eeaac3a8d7c02ae03c8426f3...

随后我捕获服务器时间和随机字节并将其保存为 srnd.bin

Random: 5b6894043bb1289e158b0278ef66dc53c9fa71e75e900739...
    GMT Unix Time: Aug  6, 2018 14:31:32.000000000 Eastern Daylight Time
    Random Bytes: 3bb1289e158b0278ef66dc53c9fa71e75e900739af2657cd...

Dave,此时我很困惑我可能遗漏了什么。我不认为我遗漏了变量中的空值之类的东西,或者我已经仔细检查了数据和步骤,但没有发现我可能遗漏了什么。你发现这些步骤有什么问题吗?谢谢

相关内容