Загадка Евклида (Euclid's Riddle)
Загадка Евклида (Euclid's Riddle)
Platform: CUSTOM | Category: Crypto | Type: Challenge | Difficulty: Easy | OS: N/A | **Author: XESXOR Techniques: Known plaintext attack using flag format, Mathematical constant as encryption key, XOR key recovery from partial ciphertext
Summary
Walkthrough of the CUSTOM Crypto Загадка Евклида (Euclid's Riddle). ``` 7A 6A 75 72 6C 76 48 54 09 54 5C 04 7A 66 4A 0D 40 71 04 67 7F 51 03 5D 67 75 08 5D 47 04 02 5B 62 4E
Description
7A 6A 75 72 6C 76 48 54 09 54 5C 04 7A 66 4A 0D 40 71 04 67 7F 51 03 5D 67 75 08 5D 47 04 02 5B 62 4E
На столе в кабинете математика кто-то оставил загадочную записку с этим текстом.
Помоги разобраться, что это может значить.
Analysis
- Ciphertext: 34 bytes in hexadecimal format
- Task name: "Euclid's Riddle" — direct hint to Euclid, who first described the Golden Ratio in "Elements"
- Context: "mathematician's office" — points to a mathematical constant
Known Plaintext Attack
Knowing the flag format KFCCTF{, XOR the first 7 bytes of ciphertext:
0x7A ^ 'K' = 0x31 = '1'
0x6A ^ 'F' = 0x2C = ','
0x75 ^ 'C' = 0x36 = '6'
0x72 ^ 'C' = 0x31 = '1'
0x6C ^ 'T' = 0x38 = '8'
0x76 ^ 'F' = 0x30 = '0'
0x48 ^ '{' = 0x33 = '3'
Result: "1,61803" — the beginning of the Golden Ratio (φ = 1.618033988749894...)!
Golden Ratio (φ)
φ = (1 + √5) / 2 ≈ 1.618033988749894848204586834365638...
Euclid first defined this proportion in his "Elements" (Book VI, Definition 3).
Solution
python read-only • copy allowed#!/usr/bin/env python3 from decimal import Decimal, getcontext # Set precision for calculating φ getcontext().prec = 50 # Calculate the Golden Ratio phi = (Decimal(1) + Decimal(5).sqrt()) / 2 # Use comma as decimal separator (European format) phi_str = str(phi).replace('.', ',') print(f"φ = {phi_str[:40]}...") # Ciphertext ciphertext = bytes.fromhex( "7A 6A 75 72 6C 76 48 54 09 54 5C 04 7A 66 4A 0D " "40 71 04 67 7F 51 03 5D 67 75 08 5D 47 04 02 5B 62 4E" ) # Key — string representation of φ key = phi_str.encode() # XOR decryption flag = bytes(c ^ k for c, k in zip(ciphertext, key)) print(f"Flag: {flag.decode()}")
Output
φ = 1,6180339887498948482045868343656381177...
Flag: KFCCTF{REDACTED}
Mathematical Constants for CTF
| Constant | Value | Association |
|---|---|---|
| φ (phi) | 1.618033988749... | Euclid, Fibonacci |
| π (pi) | 3.141592653589... | Archimedes |
| e | 2.718281828459... | Euler |
| √2 | 1.414213562373... | Pythagoras |
References
- Golden Ratio - Wikipedia
- Euclid's Elements
Key Takeaways / Lessons
- Mastering Known plaintext attack using flag format, Mathematical constant as encryption key, XOR key recovery from partial ciphertext was key to this challenge.
- Always check for common misconfigurations and verify assumptions.
Crafted by XESXOR Research • 2025-12-30 • CUSTOM • Загадка Евклида (Euclid's Riddle) • Difficulty: Easy