Description: Our data got corrupted on the way here. Luckily, nothing got replaced, but every block of 3 got scrambled around! The first word seems to be three letters long, maybe you can use that to recover the rest of the message.
Difficulty: Medium
Author: Will Hong
Summary
In this challenge, we are given a corrupted message where every group of three characters has been scrambled, but no characters were lost or replaced. By leveraging the hint that the first word is three letters long, we can identify the scrambling pattern and apply it consistently across the entire ciphertext to recover the flag.
This is a classic block transposition cipher.
Analysis
We are provided with a file named message.txt:
$ file message.txtmessage.txt: ASCII text, with no line terminatorsIts content:
$ cat message.txtheTfl g as iicpCTo{7F4NRP051N5_16_35P3X51N3_V091B0AE}2The challenge name (transposition-trial) and the description strongly suggest a transposition cipher, where characters are rearranged but not modified.
To confirm, we can use dCodeβs Cipher Identifier.

Yep, I was right, itβs Transposition Cipher.
What is Transposition Cipher?
A transposition cipher encrypts a message by rearranging the order of characters according to a fixed pattern or key, without changing the characters themselves.
Key properties:
- No substitution occurs
- Character frequency remains the same
- Decryption requires discovering the correct permutation
Encryption
In this challenge, the permutation is applied per block of 3 characters. The plaintext is divided into blocks of 3 characters, and each block is scrambled according to a fixed pattern.
For example, if we have a block abc and the pattern is a specific permutation, the encrypted block might be cab or bac depending on the pattern used.
Decryption
To decrypt, we need to:
- Identify the correct permutation pattern used for scrambling
- Reverse that pattern (apply the inverse permutation) to each block of 3 characters
- Concatenate the decrypted blocks to recover the plaintext
The hint tells us the first word is three letters long, which is likely βTheβ. This gives us a known plaintext-ciphertext pair:
- Ciphertext:
heT - Plaintext:
The
From this, we can determine the permutation pattern.
Solution
Step 1: Determine the permutation pattern
The first block heT should decrypt to The. Letβs map the positions:
The plaintext is The, encrypted as heT. To encrypt:
T(index 0) β position 2 (becomesTat the end)h(index 1) β position 0 (becomeshat the start)e(index 2) β position 1 (becomesein middle)
So the encryption pattern is: [1, 2, 0] (take char at 1, then 2, then 0 of original)
To decrypt, we need the inverse permutation. If encryption uses pattern [1, 2, 0], decryption uses [2, 0, 1]:
- Encrypted position 0 β goes to plaintext position 2
- Encrypted position 1 β goes to plaintext position 0
- Encrypted position 2 β goes to plaintext position 1
Step 2: Implement the decryption
Letβs verify with the first block heT:
- Apply pattern
[2, 0, 1]:[2]:heT[2] =Tβ position 0[0]:heT[0] =hβ position 1[1]:heT[1] =eβ position 2- Result:
Theβ
Hereβs a Python solution:
ciphertext = "heTfl g as iicpCTo{7F4NRP051N5_16_35P3X51N3_V091B0AE}2"
# inverse permutation of [1, 2, 0]perm = [2, 0, 1]
plaintext = ""
for i in range(0, len(ciphertext), 3): block = ciphertext[i:i+3] if len(block) == 3: plaintext += ''.join(block[p] for p in perm) else: plaintext += block # handle leftover chars if any
print(plaintext)Step 3: Decrypt the entire message
Running the decryption function on the ciphertext :
picoCTF{7R4N5P051N6_15_3XP3N51V3_109AB02E}
β‘ Raikiriπ Flag pwned!
$ python solve.pyThe flag is picoCTF{7R4N5P051N6_15_3XP3N51V3_109AB02E}π‘ TL;DR / Lesson Learned
- Known plaintext attack: The hint that the first word is three letters (likely βTheβ) was crucial for determining the permutation pattern.
- Block transposition with fixed pattern: Once we identified the pattern from one block, we could apply it consistently to all other blocks.
- No character substitution: This confirms itβs purely a transposition, not a substitution cipher - all characters remain unchanged, just reordered within each 3-character block.
- Inverse permutation: To decrypt, we need to apply the mathematical inverse of the encryption permutation to reverse the scrambling.