Skip to main content
Challenges Replacing parameter g
Cryptography Medium DH attacks Solves: 5

Replacing parameter g

Author: CyberSamSU
Points
45

In many protocols, the p and g parameters are transmitted within the message and the receiver uses them without verifying. A man-in-the-middle can replace g at exactly this point — then the shared secret becomes known in advance.

Three classic injections:

  • g = 1 — any power of 1 is 1.
  • g = p — p ≡ 0 (mod p), meaning everything turns into zero.
  • g = p-1 — this element is equal to -1, its order is only 2; its power takes only one of two values.

Below are three recorded sessions of a single server. In each of them, Mallory replaced g. The secret numbers a and b are unknown — but they are not needed anyway.

p = 358495712203025531
g (haqiqiy) = 2

1-sessiya:  g' = 1
            A = 1
            B = 1

2-sessiya:  g' = p
            A = 0
            B = 0

3-sessiya:  g' = p - 1
            A = 358495712203025530
            B = 358495712203025530

Find the shared secret of all three sessions: s₁, s₂, s₃.

Flag: BAYROQ{DH_g_ineksiya_<s1>_<s2>_<s3>}

Hints 3
Opening a hint reduces the points you get for solving this challenge.
Hint 1 −4 pts Log in
Hint 2 −9 pts Log in
Hint 3 −13 pts Log in
To submit a flag, log in.

First solvers

1. Лазиз 04.10.2026
2. testrejim 09.10.2026
3. Mirjaxon Qaxxarov 27.10.2026
4. Odam 05.11.2026
5. arcanum 11.11.2026