This is one of the simplest and well-known cipher, the Ceasar cipher, named after Julius Ceasar. Basically, It is a type of substitution cipher where each letter in the plaintext is encrypted by replacing with another letter at a fixed number of position down the alphabet.
Ex: Ceasar cipher using right shift of 13 (ROT13):
| Num | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Plain | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z |
| Cipher | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | A | B | C | D | E | F | G | H | I | J | K | L | M |
There are only 26 English letters, so breaking the cipher is not a big deal at all. It is vulnerable to a brute-force attack, where all 25 possible shifts are tried to see which one makes sense.
Example: cvpbPGS{arkg_gvzr_V'yy_gel_2_ebhaqf_bs_ebg13_uJdSftmh}
You can do crack this by:
from string import ascii_lowercase
alphabet = ascii_lowercase # a-z
cipher = "cvpbPGS{arkg_gvzr_V'yy_gel_2_ebhaqf_bs_ebg13_uJdSftmh}".lower()
# just lower the cipher, avoiding uppercase
for i in range(26): # loop from 0 to 25
cipher = "".join([ alphabet[(alphabet.index(cipher[x])+i)%26] if cipher[x] in alphabet else cipher[x] for x in range(0,len(cipher)) ])
if "picoctf" in cipher:
print("Flag found!",cipher)
break
# Flag found! picoctf{next_time_i'll_try_2_rounds_of_rot13_hwqfsgzu}
# remember to change back those uppercase letters