Decoding ROT using the Echo and Tr Commands in your Linux Terminal

April 8, 2012, by | Start Discussion

ROT which is known as the Caesar Cipher is a kind of cryptography wherein encoding is done by moving the letters in the alphabet to its next letter. There are 25 possible ROT settings which covers the scope of letters A-Z. Thus in ROT-1, A is equals to B and B is equals to C and so are the next letters but Z would go back to A. And so the ROT-1 cipher of ‘ProjectX‘is ‘QspkfduY‘. Thus, ROT = rotation.

In this short write up we will be using the echo and tr bash commands in your Linux terminal to encode or decode letters using ROT cipher. The ‘echo’ command is a built-in command in Bash in C shells which repeats the letters of words after it. For example:

 

It would echo the word “ProjectX”=). Thus, the command is used to write its arguments to standard output. Another command that we will be using is the tr command which translates characters. I saw in pastebin different implementations in different programming languages to decode ROT and that most of them are using the TR application so why not mixed it with the echo command? Alright here it goes, for example QspkfduY is ROT-1 and so I can decode it using echo “QspkfduY” | tr ‘b-za-aB-ZA-A’ ‘a-zA-Z’.

 

To decode the ROT-2 ProjectX which is “RtqlgevZ”, I can just change “b-za-aB-ZA-A” to “c-za-bC-ZA-B”.

 

This list should help you to decode ROT-3 to ROT-25:

ROT-3 = tr ‘d-za-cD-ZA-C’ ‘a-zA-Z’
ROT-4 = tr ‘e-za-dE-ZA-D’ ‘a-zA-Z’
ROT-5 = tr ‘f-za-eF-ZA-E’ ‘a-zA-Z’
ROT-6 = tr ‘g-za-fG-ZA-F’ ‘a-zA-Z’
ROT-7 = tr ‘h-za-gH-ZA-G’ ‘a-zA-Z’
ROT-8 = tr ‘i-za-hI-ZA-H’ ‘a-zA-Z’
ROT-9 = tr ‘-za-iJ-ZA-I’ ‘a-zA-Z’
ROT-10 = tr ‘k-za-jK-ZA-J’ ‘a-zA-Z’
ROT-11 = tr ‘l-za-kL-ZA-K’ ‘a-zA-Z’
ROT-12 = tr ‘m-za-lM-ZA-L’ ‘a-zA-Z’
ROT-13 = tr ‘n-za-mN-ZA-M’ ‘a-zA-Z’
ROT-14 = tr ‘o-za-nO-ZA-N’ ‘a-zA-Z’
ROT-15 = tr ‘p-za-oP-ZA-O’ ‘a-zA-Z’
ROT-16 = tr ‘q-za-pQ-ZA-P’ ‘a-zA-Z’
ROT-17 = tr ‘r-za-qR-ZA-Q’ ‘a-zA-Z’
ROT-18 = tr ‘s-za-rS-ZA-R’ ‘a-zA-Z’
ROT-19 = tr ‘t-za-sT-ZA-S’ ‘a-zA-Z’
ROT-20 = tr ‘u-za-tU-ZA-T’ ‘a-zA-Z’
ROT-21 = tr ‘v-za-uV-ZA-U’ ‘a-zA-Z’
ROT-22 = tr ‘w-za-vW-ZA-V’ ‘a-zA-Z’
ROT-23 = tr ‘x-za-wX-ZA-W’ ‘a-zA-Z’
ROT-24 = tr ‘y-za-xY-ZA-X’ ‘a-zA-Z’
ROT-25 = tr ‘z-za-yZ-ZA-Y’ ‘a-zA-Z’

Take note of this technique, this guide might be useful in CFP for other hacking and information security conventions out there.


Jay Turla is a programming student and Infosec enthusiast from the Philippines. He is one of the bloggers of ROOTCON (Philippine Hackers Conference) and The ProjectX Blog. (http://www.theprojectxblog.net/)

Leave a Reply