Overview
This is a chained crypto challenge: Stage 1 (The Downlink, steganography) hides a 12-character relay token inside a PNG frame; Stage 2 (The Uplink) uses that token to derive an AES-256-CBC key, unwraps an outer encryption layer, then breaks a carelessly generated RSA key to recover an intercepted command containing the next relay token.
Prerequisites / Setup
- Python 3 (
PIL/Pillow,sympy,hashlib,Crypto.Cipher.AES) downlink_frame.png(Stage 1 artifact) anduplink.enc(Stage 2 artifact)
Recon
Step 1 — Recover the relay token from Stage 1
Goal: Extract the LSB-embedded relay token from downlink_frame.png.
Stage 1 (blackstar1_the_downlink/downlink_frame.png) is a 720×540 RGB PNG. The least significant bits of the RGB channels, read left-to-right top-to-bottom, contain an ASCII marker:
BLACKSTAR//DOWNLINK//RELAY_TOKEN=007161435C98//KEEP THIS 12-CHAR TOKEN - THE UPLINK LAYER IS LOCKED WITH IT::END::
Stage 1 relay token: 007161435C98.
Step 2 — Inspect uplink.enc
Goal: Confirm the encrypted payload format and recover the JSON payload.
Stage 2 (uplink.enc) format: [16-byte IV][ciphertext], AES-256-CBC with key = SHA-256(relay_token). Decryption yields a JSON payload:
{
"note": "Intercepted uplink command (textbook RSA, no padding).",
"n": <1024-bit modulus>,
"e": 65537,
"c": <ciphertext>
}
Vulnerability Analysis
The flaw classes are Textbook RSA (CWE-327: Use of a Broken or Risky Cryptographic Algorithm) and RSA with closely-spaced primes (small-prime-difference / Fermat-factorable modulus).
Exploitation
Step 3 — Derive the AES key and unwrap the layer
Goal: Decrypt uplink.enc to recover the RSA parameters.
Key = SHA-256(“007161435C98”), IV = first 16 bytes of uplink.enc. Decrypt and strip PKCS7 padding to obtain the JSON payload shown above.
Step 4 — Factor the RSA modulus
Goal: Recover p and q from the 1024-bit modulus n.
The two primes are extremely close together. sympy.factorint recovers them instantly:
p = ...2199459236459
q = ...2236110196301
Step 5 — Recover the private exponent and decrypt
Goal: Compute d = e⁻¹ mod φ(n) and decrypt c with textbook RSA.
φ(n) = (p−1)(q−1), d = e⁻¹ mod φ(n). The ciphertext is textbook RSA (no padding), so m = cᵈ mod n yields:
BLACKSTAR//UPLINK//RELAY_TOKEN=9402A282B212//NEXT:FLIGHT-COMPUTER//keep token::END::
The next relay token is 9402A282B212.
Flag
FLAG{REDACTED}
Lessons / Takeaways
- Chained stages require cross-category context: Stage 1’s steganographic token is the cryptographic key material for Stage 2 — nothing in
uplink.encis solvable without it. - Textbook RSA without padding is trivially broken once the modulus is factored: the raw plaintext is recoverable directly from
m = cᵈ mod n. - Careless prime generation defeats RSA: the two primes were generated too close together, making factorization trivial. Primes must be independently random and of comparable but not correlated size.
Mitigations
- Use RSA-OAEP (PKCS#1 v2.2) instead of textbook RSA; never encrypt raw plaintext with
c = mᵉ mod n. - Generate primes independently and randomly with a CSPRNG; reject any pair that is too close together (Fermat-factorable).
- Use key sizes of at least 2048 bits.
Techniques
- LSB Steganography
- AES-CBC
- RSA
- Textbook RSA
- Small Prime Difference
References
- Boneh, “Twenty Years of Attacks on the RSA Cryptosystem”: https://crypto.stanford.edu/~dabo/pubs/abstracts/RSA-survey.html
- Fermat factorization method: https://en.wikipedia.org/wiki/Fermat%27s_factorization_method
- PKCS#1 v2.2: RSA Cryptography Standard: https://www.rfc-editor.org/rfc/rfc8017

