DawgCTF 2025 - Guess Me If You Can

Published: April 22, 2025 | CTF: DawgCTF 2025
CTF Crypto PRNG

Guess Me If You Can (CRYPTO)

Category Cryptography
Points 300
Difficulty Hard
Guess Me If You Can Challenge Description

This challenge involves predicting the output of a Linear Congruential Generator (LCG), a type of pseudorandom number generator. The key to this challenge is understanding how LCGs work and how to exploit their deterministic nature.

Guess Me If You Can Server Code
Key Insights from the Server Code:
1. Admin account creation is important: The admin account is created first, with its password being the first output of the LCG after the initial seed.
2. Possible alternating pattern: Some password transitions follow an a=3 prediction while others don't, suggesting there might be a pattern that alternates or changes in some way.
3. Working backwards is key: If we can understand the pattern between consecutive passwords, we can work backwards from the first user password to the admin password.

Understanding Linear Congruential Generators (LCGs)

An LCG generates a sequence of pseudorandom numbers using the recurrence relation:

X_{n+1} = (a * X_n + b) % m

Where:

The challenge is to determine these parameters by observing the generated passwords, then use this knowledge to predict the admin password.

The Attack Strategy

I developed a script that:

  1. Registers 10 users to get a longer sequence of passwords
  2. Analyzes the differences between consecutive passwords
  3. Looks for consistent or alternating patterns in the sequence
  4. Tries to identify the LCG parameters (a and b)
  5. Generates admin password candidates based on different hypotheses
  6. Tests each candidate by attempting to log in
Script Analysis of LCG
Python Exploit Script Part 1 Python Exploit Script Part 2

After analyzing the sequence of generated passwords, I was able to determine that the server was using an LCG with specific parameters. By understanding how the passwords were generated, I could predict the admin password and successfully log in.

[+] Registering multiple users to collect password samples... [+] Analyzing password patterns... [+] Testing different LCG parameters... [+] Found likely admin password! [+] Attempting login with candidate... [+] Login successful!
Successful Login
FLAG: DawgCTF{PRNGs_d0nt_m4k3_f0r_g00d_p455w0rd5}
Key Learning: This challenge demonstrates why using predictable pseudorandom number generators for security-critical applications like password generation is dangerous. Once an attacker can determine the parameters of the PRNG, they can predict past and future outputs.