Home
Writeups Misc About
Export Grade

Export-grade

This challenge is simulating the infamous Logjam attack on many internet protocols like HTTPS, SSH, IPsec, SMTPS and protocols rely on TLS that uses Diffie-Hellman key exchange. The Logjam attack allows a man-in-the-middle attacker to downgrade vulnerable TLS connections to 512-bit export-grade cryptography, as there is an option for clients back when the paper is published to use DHE_EXPORT level of security. There is no indication of the cipher suites the server has chosen, so a MiTM can easily modify the client's ciphersuite to be DHE_EXPORT. More information can be found in this paper.

This idea is used in the challenge. Initially, Alice offered a list containing the list of supported ciphersuites, ranging from DH1536 to DH64. There is nothing to stop us from modifying this message, hence we can pick the weakest option in the list, which is DH64. Afterwards, the usual key-exchange is performed, and we got information of the g, p, A, B and the iv, encrypted_flag generated from the shared secret.

Python Implementation to obtain the above information:

Again, DH64 is weak, and a brute-force attack to derive the secret of either Alice and Bob can be performed on a laptop. I initially pick the Baby-step-Giant-step (BSGS) algorithm. Unfortunately, this did not end up well as the space on my hard drive got wiped out in seconds. Also, the runtime is very slow O(n), where n=264. Hence, the approach to solve this using simple Python code using BSGS is not possible.

Another solution is to use Pohlig-Hellman algorithm. The prime is weak (we can always take a look at FactorDB) and hence the number should be smooth. Or we can skip all of this work and use the discrete_log functionality provided by Sage. Sage unfortunately has some problems with installing pwntools, so at the end of the above Python script I decided to print out everything to solve the discrete log problem on Sage.

Sage Implementation