OverTheWire Bandit: Level 11 → Level 12
•
Technical Note
Context
One of the oldest methods of encryption involves shifting letters. The “Caesar Cipher,” used by Julius Caesar, is a prime example. ROT13 (Rotate by 13 places) is a special case of this method.
The Latin alphabet has 26 letters. The number 13 represents exactly half. This means if you apply ROT13 to a text, it gets encrypted; if you apply it again, it gets decrypted (returns to the original).
A → N B → O … N → A
Goal
The data.txt file is encrypted with ROT13. We need to decode it to retrieve the original text.
Solution
To translate or delete characters in Linux, we use the tr (translate) command.
To perform the ROT13 operation, we set up the following logic:
- Source set:
A-Za-z(All uppercase and lowercase letters) - Target set:
N-ZA-Mn-za-m(shifted by 13 positions)
Here is our command:
cat data.txt | tr 'A-Za-z' 'N-ZA-Mn-za-m'
Command Breakdown:
'A-Za-z': Characters to be replaced. All letters from A to Z and a to z.'N-ZA-Mn-za-m': The corresponding replacement characters.AbecomesN.MbecomesZ.Nwraps around toA.- The same logic applies to lowercase letters (
a->n).
Output:
The password is: JVNBBFSmZwKKOP0XbFXOoW8chDz5yVRv
Password decrypted!
Key Takeaways
- ROT13: A simple letter substitution cipher. It provides no real security, only obfuscation (making text unreadable).
trCommand: Operates on a character-by-character basis. Unlikesed, which works with strings or patterns,tris purely for mapping one set of characters to another. For example, it can also be used to capitalization:tr 'a-z' 'A-Z'.