The Challenge
A dashed.txt file full of Morse code symbols. The flag is buried under five successive encoding layers. The comment in the script says it best: “BASTA FARLO CON CYBERCHEF MA NON AVEVO NULLA DA FARE” (you could just use CyberChef, but I had nothing better to do) — that is the honest summary of this challenge.
Approach
Working backwards through the layers:
- Morse decode: split the file on spaces, reverse-lookup each symbol in a dictionary to get a character.
- Strip hex noise: the Morse decodes to something like
0X4A,0X15,.... Strip0Xand commas, split on spaces. - Hex to bytes: each remaining segment is a two-character hex value; decode it.
- Binary string: concatenate the resulting bytes to get a binary string (
0and1characters). - Binary to text: convert the binary string to an integer, then to bytes → gives a Base64 string.
- Base64 decode: yields a Caesar-shifted string.
- Caesar decode: the shift is
ord(first_char) - ord('f')— the first letter should bef(start offlag{), so the shift is derived directly from the ciphertext.
Solution
|
|
The Morse decode builds temp_string by reverse-looking up each symbol. After stripping 0X and commas, each remaining token is two hex digits — concatenating their ASCII decodes gives a string of 0 and 1 characters. int(flag2, 2).to_bytes(...) is the binary-to-bytes step. b64decode unwraps the Base64 layer. The Caesar shift is derived by comparing the first character against 'f' — valid since every flag starts with flag{.
What I Learned
Heavily layered encoding challenges reward systematic peeling: work from the outermost layer inward, verify each step produces human-readable output, and never assume you know the layer count until output looks like a flag. The Caesar key derivation trick (compute shift from known first character) is broadly applicable to any encoding where you know one plaintext output char.