Description
Every block of three characters in the message was permuted: positions (0,1,2) became (2,0,1). Undo the pattern to read the plaintext flag.
Setup
Download message.txt and note that “The flag” appears if you reorder each triple of characters.
Write a short script (Python shown below) to iterate through the text in steps of three and rearrange the characters back to their original order.
wget https://artifacts.picoctf.net/c/191/message.txt
python3 - <<'PY'
flag = []
with open('message.txt') as f:
data = f.read()
for i in range(0, len(data), 3):
block = data[i:i+3]
if len(block) == 3:
flag.append(block[2] + block[0] + block[1])
print(''.join(flag))
PY
Solution
- Step 1Deduce the permutationBecause the first word should read “The”, you can infer the mapping. Each chunk `[a b c]` was scrambled to `[b c a]` (or equivalently, to recover the original, take `[c a b]`).
- Step 2Automate the swapLoop through the ciphertext in steps of 3, reassemble each block as `block[2] + block[0] + block[1]`, and concatenate the results. The final sentence ends with picoCTF{...}.
Flag
picoCTF{7R4N5P051N6_15_3XP3N51V3_56E6...}
Any language works; just be careful with the final block if the length isn’t divisible by three.