Lesson 12 of 12
Lab 12 — Capture the Flag Finale
A multi-stage CTF combining encoding, crypto, web and forensics skills to find the hidden flags.
Learn it
A Capture the Flag (CTF) is a legal security competition where you solve puzzles to find hidden 'flags'.
Each flag looks like FLAG{something}. Find it, submit it, score points.
CTFs mix skills: decoding, cracking, spotting web bugs and reading evidence.
Key terms
- CTF
- Capture the Flag — a legal hacking competition with puzzle challenges.
- Base64
- An encoding that turns bytes into text characters; easily reversed.
- ROT13
- A Caesar cipher shifting each letter by 13.
- XOR
- A bitwise operation used in simple ciphers; applying the same key twice reverses it.
- Write-up
- A report explaining how you solved a challenge.
Stage-by-stage flag hunt
Solve each stage — the answer to one unlocks the next.
- 1Stage 1 — Encoding: RkxBR3tiYXNlNjRfaXNfbm90X2NyeXB0b30= → decode Base64 → FLAG{base64_is_not_crypto}
- 2Stage 2 — Cipher: SYNT{ebg13_vf_rnfl} → apply ROT13 → FLAG{rot13_is_easy}
- 3Stage 3 — Web: A login page comment says <!-- TODO remove test user guest/guest -->. Lesson: never leave secrets in HTML.
- 4Stage 4 — Forensics: An image's metadata comment field contains the next flag. Always check metadata.
- 5Stage 5 — Logic: The final flag is hidden in robots.txt under Disallow: /secret-admin. robots.txt is public — it hides nothing.
- 6Debrief: Every stage was a real-world mistake: weak encoding, old ciphers, leaked comments, metadata and 'security through obscurity'.
Decoder toolkit
pythonimport base64, codecs
s1 = 'RkxBR3tiYXNlNjRfaXNfbm90X2NyeXB0b30='
print(base64.b64decode(s1).decode())
s2 = 'SYNT{ebg13_vf_rnfl}'
print(codecs.decode(s2, 'rot13'))
def xor(data: bytes, key: bytes):
return bytes(b ^ key[i % len(key)] for i, b in enumerate(data))
secret = xor(b'FLAG{xor_twice}', b'k')
print(xor(secret, b'k')) # XOR again to reverseThree tiny tools solve most beginner CTF crypto: Base64 decoding, ROT13 and XOR. Notice XOR with the same key undoes itself.
Try it
What does this print?
pythonimport codecs
print(codecs.decode('SYNT{pgs}', 'rot13'))Challenge
Solve all five stages and write a short CTF write-up: for each stage give the flag, the technique you used and the real-world security lesson.
Pick whichever way suits you — every mode earns the same bonus XP.
Write at least 40 more characters to submit.
Mark your own work
Guided walkthrough — 0/4 clues revealed
- Clue 1 locked — reveal it only if you get stuck.
- Clue 2 locked — reveal it only if you get stuck.
- Clue 3 locked — reveal it only if you get stuck.
- Clue 4 locked — reveal it only if you get stuck.
Each clue costs 11 XP (never below 55 XP). You'd earn 110 XP right now.
Extension: Create your own 3-stage mini CTF for a classmate using Base64, ROT13 and a hidden comment.