PINK CTFMisc
🍰 (Pie)
The ciphertext is the flag XORed with digits of π. The digits are read three at a time ("three of them"), each 3-digit number is reduced mod 256, and the stream starts at decimal place 1338 of π, just past the category…
- Competition
PINK CTF
- Category
- MiscMedium · estimated
- Source status
- Source-documented · not platform-verified
- Document
- PDF edition2 min read
TL;DR
The ciphertext is the flag XORed with digits of π. The digits are read three at a time ("three of them"), each 3-digit number is reduced mod 256, and the stream starts at decimal place 1338 of π, just past the category name "1337".
01
Known plaintext
The ciphertext is 25 bytes, exactly the length of a PINK{...} flag, so this is a length-preserving stream (XOR). XORing the first bytes with PINK{ gives the keystream prefix:
73 66 5d 14 06 ^ P I N K { = 23 2f 13 5f 7d (35, 47, 19, 95, 125)The keystream is not periodic: no repeating key of length 1 to 12 decrypts to printable text, and it contains non-printable bytes, so it isn't a text password. π digits used directly (as ASCII, as single digits, as digit pairs, as binary/hex expansion, as a big integer, in other bases) don't match either.
02
Three digits at a time
"Thr33 0f th3m" means three digits per key byte. A 3-digit group goes up to 999, so it has to be reduced mod 256 to fit a byte. Searching the first 100,000 digits of π for five consecutive 3-digit groups that give 35 47 19 95 125 mod 256 finds exactly one hit:
digit string "31415926..." index 1338 (decimal place 1338):803 815 019 351 125 ...803 % 256 = 35, 815 % 256 = 47, 19, 351 % 256 = 95, 125The starting position sits right after 1337, the challenge category.
03
Decrypting
solve.py takes 25 groups from that position and XORs:
$ python solve.pygroups: [803, 815, 19, 351, 125, 338, 243, 3, 558, 764, 24, 749, 647, 326, 391, 419, 927, 260, 426, 992, 279, 678, 235, 478, 163]flag: PINK{That_Pie_Was_Yummy!}Flag
Flag
PINK{That_Pie_Was_Yummy!}
Source-documented · not platform-verified
