密码学实战 - HTB Nuclear Sale

146 阅读2分钟

概述

Nuclear Sale是来自于HTB(hackthebox.com)的一个容易级密码学挑战,完成该挑战所需要掌握的知识点在于pcap文件分析和XOR计算。

题目分析

相关的任务文件提供了一个challenge.pcap文件,任务说明中提及了邮件服务器交互记录。

解题过程

首先使用Wiresharkchallenge.pcap文件进行分析, 从中我们可以获取如下的几个交互信息。

We are very XORry but the management ...

加密算法与XOR相关。
... His information is encrypted below:

6b65813f4fe991efe2042f79988a3b2f2559d358e55f2fa373e53b1965b5bb2b175cf039

要破解的密文
Here is the ciphertext encrypted with our key.

fd034c32294bfa6ab44a28892e75c4f24d8e71b41cfb9a81a634b90e6238443a813a3d34

密文1
Encrypting again with our key...

de328f76159108f7653a5883decb8dec06b0fd9bc8d0dd7dade1f04836b8a07da20bfe70

密文2

根据以上信息,我们可以使用如下代码获取明文

from Crypto.Util.number import bytes_to_long, long_to_bytes 

#要破解的密文
m1 = 0x6b65813f4fe991efe2042f79988a3b2f2559d358e55f2fa373e53b1965b5bb2b175cf039

#密文1
c1 = 0xfd034c32294bfa6ab44a28892e75c4f24d8e71b41cfb9a81a634b90e6238443a813a3d34

#密文2
c2 = 0xde328f76159108f7653a5883decb8dec06b0fd9bc8d0dd7dade1f04836b8a07da20bfe70

#密文1 xor 密文2 = 密钥 
x = c1 ^ c2

#明文 = m1 xor 密钥
FLAG = long_to_bytes(m1 ^ x)
print("FLAG = ", FLAG)