PINK CTFMisc
Journey
gogogo.journey is a program that decodes an embedded blob and writes out the next program, in a different language, together with a hint for the next step. The chain is nine languages deep:
- Competition
PINK CTF
- Category
- MiscHard · estimated
- Source status
- Source-documented · not platform-verified
- Document
- PDF edition4 min read
TL;DR
gogogo.journey is a program that decodes an embedded blob and writes out the next program, in a different language, together with a hint for the next step. The chain is nine languages deep:
Go → C → Python → Rust → Haskell → Java → Brainfuck → Ruby → Emojicode → flagEach layer uses throwaway obfuscation (XOR, rotates, offsets, zlib, AES-GCM) and is full of dead "decoy" branches guarded by conditions that can never be true. I ran the layers that are easy to run (C in WSL with gcc, Python, Java) and ported the rest to small Python scripts.
Every layer's file name and printed message is hex XORed with 0xAA (once with 0xBB).
01
Go → standard.journey
A 75-million-character hex constant gogogo. Each byte is decoded as:
t = ct[i] - ((i*i + 31*i + 107) & 0xFF)u = t * 13pt[i] = ror1(u)The first 4 bytes are a big-endian length, followed by the payload. The decoy.bin and fnv checks are dead code. Ported in layer1_go.py (numpy, a few seconds).
"This Google language is a bit unusual, maybe I should go back to the standard"
02
C → snake.journey
There are 37 MB of static const u8 Lxx[] arrays, one per output line, each decoded with an xorshift32 keystream seeded from the line index, length and a per-line salt. The program is self-contained, so I compiled and ran it in WSL with gcc -O0 -w.
"C is only one letter; less is faster, but I also want to fight snakes and see a child of C"
03
Python → rusted.journey
Ten rounds of zlib.decompress followed by XOR with sha256(s + [r] + s). It's harmless, so I just ran it.
"Python is pretty slow, I am afraid my computer has rusted by now"
04
Rust → classic.journey
A list of hex chunks, decoded as ror1(b ^ ((i*131) & 0xFF) ^ "1337coffee"[i % 10]), again with a 4-byte length prefix. Ported in layer4_rust.py.
"Now that I am all rusted up, I should use a classic again"
05
Haskell → coffee.journey
Most of the functions (r1, r3–r8) are identity functions in disguise. r9 would drop a byte only if (t .&. 15) == 17, which can never happen. What's left is pt[i] = (ct[i] - (i+1)) mod 256. Ported in layer5_haskell.py.
"Haskell was exhausting, now I need some coffee first!"
06
Java → awake.journey
The ciphertext is base64, split across the fields cappuccino_000…cappuccino_015 and gathered by reflection. It's decrypted with AES-GCM using a PBKDF2-HMAC-SHA256 key (password espresso-beans-42, 9541 iterations, 256 bits). The AAD is the output file name. I compiled and ran it as-is with the JDK.
"After so much coffee I feel wide awake; my brain is completely scrambled"
07
Brainfuck → base64 Ruby
The program uses only +, - and ., so it's a single cell where a running sum gives each output byte (layer7_bf.py). The output is:
Now I would like to mine rubies. But how?cmVxdWlyZSAiYmFzZTY0Ig...Base64-decoding the rest gives Ruby source (rubies.rb).
08
Ruby → healthy_food.journey
A small container header, JRNYv2\0\0 | rounds=6 | keylen=24 | salt(24) | gzip=1 | size=205416. The data is XORed with sha256(salt || BE32(round))[:24] for rounds 5…0, then gunzipped. The rennes/heidelberg array is unused junk. Ported in layer8_ruby.py.
"I found a ruby in the mine! But now I am really hungry for some grapes!"
09
Emojicode → flag
The last layer is Emojicode. The 🏁🍇 entry block contains 33 blocks like this:
90 ➡️ mango ...constants...↪️ 1 🙌 1 🍇 111 ➡️ 🖍🆕 grape grape ⬅️❌ mango (XOR-assign, ×8) ... ↪️ grape 🙌 65 🍇 😀 🔤A🔤❗️ 🍉 🙅↪️ grape 🙌 66 🍇 😀 🔤B🔤❗️ 🍉 ...one branch per printable characterOnly three constructs appear: constant or variable assignment, ⬅️❌ (XOR-assign), and ↪️ a 🙌 b (if-equal). layer9_emojicode.py interprets them:
Thanks for coming on this journey with me. Here is the flag:PINK{Th3_J0urn3y_m4y_n3v3r_3nd!!}Solve script
solve.py runs the whole chain from gogogo.journey. It needs WSL Ubuntu with gcc and a JDK. Each layer prints its hint:
standard.journey | This Google language is a bit unusual, maybe I should go back to the standard (standard.journey)C is only one letter; less is faster, but I also want to fight snakes and see a child of C (snake.journey)Python is pretty slow, I am afraid my computer has rusted by now (rusted.journey)classic.journey | Now that I am all rusted up, I should use a classic again (classic.journey)coffee.journey | Haskell was exhausting, now I need some coffee first! (coffee.journey)After so much coffee I feel wide awake; my brain is completely scrambled (awake.journey)healthy_food.journey | I found a ruby in the mine! But now I am really hungry for some grapes! (healthy_food.journey)Thanks for coming on this journey with me. Here is the flag:PINK{Th3_J0urn3y_m4y_n3v3r_3nd!!}Flag
Flag
PINK{Th3_J0urn3y_m4y_n3v3r_3nd!!}
Source-documented · not platform-verified
Takeaways
With matryoshka challenges, run whatever is safe to run. Only port the layers you lack a toolchain for.
Ignore the "decoy" branches: conditions like
(x & 0xF) == 0x11or(t & 15) == 17can never be true.A Brainfuck program made of only
+ - .is just a running sum, so there's no need for a full interpreter.
