Skip to main content
Challenges Unsigned DH: man-in-the-middle
Cryptography Medium DH attacks Solves: 6

Unsigned DH: man-in-the-middle

Author: CyberSamSU
Points
40

Diffie-Hellman is perfectly protected against discrete logarithms, but it has an inherent vulnerability: no one authenticates themselves in the protocol. Alice received B — but she does not know if it really came from Bob.

Mallory stands in the middle of the channel and sends M = g^m mod p with her private number m to both parties. As a result, two separate sessions emerge:

  • Alice ↔ Mallory: s₁ = A^m mod p = M^a mod p
  • Mallory ↔ Bob: s₂ = B^m mod p = M^b mod p

Neither Alice nor Bob notices anything: each generated a "shared secret" and encrypted the message. Mallory, meanwhile, reads in the middle and modifies it if necessary. This is exactly why in real TLS DH parameters are signed.

Mallory's private number m was found on their laptop, and the network capture is in the tinglangan.txt file. Read Alice's message.

Encryption method (on Alice's side):

import hashlib
def kdf(s: int) -> bytes:
    return hashlib.sha256(str(s).encode()).digest()   # 32 bayt

kalit = kdf(s1)
shifr = bytes(c ^ kalit[i % 32] for i, c in enumerate(xabar))
Attached files
tinglangan.txt Log in to download
SHA-256 checksums
tinglangan.txt: 39817e86bc2f8e0a7cfc6a8f19b4bedf0e9d898edc8d45a17d6ada68c822fa37
Hints 3
Opening a hint reduces the points you get for solving this challenge.
Hint 1 −4 pts Log in
Hint 2 −8 pts Log in
Hint 3 −12 pts Log in
To submit a flag, log in.

First solvers

1. Абдул 08.09.2026
2. Лазиз 04.10.2026
3. Mirjaxon Qaxxarov 27.10.2026
4. Odam 04.11.2026
5. arcanum 11.11.2026
6. Asmaa Mottery 25.11.2026