Caesar Cipher 2 | picoCTF ’18

caesar cipher 2 – Points: 250

Problem Statement

Can you help us decrypt this message? We believe it is a form of a caesar cipher. You can find the ciphertext in /problems/caesar-cipher-2_0_372a62ea0204b948793a2b1b3aeacaaa on the shell server.

This is a follow up to my previous post.

Message / Ciphertext

^WQ]1B4iQ/SaO@M1W>V3`AMXcABMO@3\BMa3QC`3k

This time our charset is extended from a-z to a-z , A-Z , 0-9 and printable symbols.

Source Code

This a python3 script slightly modified as written in my previous post. String module is now removed, ord() is now used to get ASCII value of character in ciphertext, and then converted back to character by chr()

ciphertext = '^WQ]1B4iQ/SaO@M1W>V3`AMXcABMO@3\BMa3QC`3k'

for key in range(1,27):
    print('key: ' + str(key) + " --> ",end='')
    
    for index in range(0,len(ciphertext)):
        print(chr(ord(ciphertext[index]) - key % 26),end='')
        

    print()
        

Result

 key: 14 --> PICO#4&[C!ESA2?#I0H%R3?JU34?A2%N4?S%C5R%]

Interesting flag is incomplete though I do got PICO in leading side and square brackets [ ] maybe enclosing flag? 🤔 🤨  But valid flag format is picoCTF{} (with curly brackets).

Decimal value for [ is 91 and for { is 123.

123 – 91 = 32 shifting is required

Final Code 

ciphertext = '^WQ]1B4iQ/SaO@M1W>V3`AMXcABMO@3\BMa3QC`3k'

for key in range(1,27):
    print('key: ' + str(key) + " --> ",end='')
    
    for index in range(0,len(ciphertext)):
        print(chr(ord(ciphertext[index]) + 32 - key % 26),end='')
        

    print()
        

Result

picoCTF{cAesaR_CiPhErS_juST_aREnT_sEcUrE}

Found 🚩🚩🚩

Leave a comment