IceCTF - 30 - Substituted - Cryptography

Information#

Version#

By Version Comment
noraj 1.0 Creation

CTF#

Description#

We got a substitute flag, I hear they are pretty lax on the rules... crypted.txt

Solution#

  1. It's a substitution cipher.
  2. I used The Black Chamber for frequence analysis.
  3. And then I continued to analyze manually with the help of my tool:
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python

import sys
import string

alphabet_letters = string.ascii_letters

# ciphered_text:plain_text (c:v)
substitution_dict = {'a':'p' ,'b':'b' ,'c':'m', 'd':'s', 'e':'o', 'f':'*',
'g':'w', 'h':'*', 'i':'k', 'j':'a', 'k':'t', 'l':'h',
'm':'n', 'n':'*', 'o':'r', 'p':'*', 'q':'g', 'r':'y',
's':'u', 't':'f', 'u':'d', 'v':'c', 'w':'i', 'x':'v',
'y':'e', 'z':'l'}

alphabet_substituted = ""
for c in alphabet_letters:
if c in string.ascii_lowercase:
alphabet_substituted += substitution_dict[c]
elif c in string.ascii_uppercase:
if substitution_dict[c.lower()] is not '*':
alphabet_substituted += substitution_dict[c.lower()].upper()
else:
alphabet_substituted += substitution_dict[c.lower()]

with open("crypted.txt", "r") as fh:
encoded_data = fh.read()

if (sys.version_info > (3, 0)):
# made with python 3.5.2
table = str.maketrans(alphabet_letters, alphabet_substituted)
else:
# made with python 2.7.12
table = string.maketrans(alphabet_letters, alphabet_substituted)

decoded_data = encoded_data.translate(table)

print("=== Encoded data ===")
print(encoded_data)
print("=== Decoded data ===")
print(decoded_data)
  1. And I executed it:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
python substitution.py
=== Encoded data ===
Lw!

Gyzvecy ke WvyVKT!

W'zz by reso dsbdkwksky tzjq teo kly ujr. Teo keujr, gy joy dksurwmq bjdwv vorakeqojalr jmu wkd jaazwvjkwemd. Vorakeqojalr ljd j zemq lwdkeor, jzklesql gwkl kly juxymk et vecaskyod wk ljd qekkym oyjzzr vecazwvjkyu. Decy dwcazy ezu vwalyod joy kly Vjydjo vwalyo, kly Xwqymyoy vwalyo, kly dsbdkwkskwem vwalyo, glwvl wd klwd emy, jmu de em. Jzcedk jzz et klydy vwalyod joy yjdwzr boeiym keujr gwkl kly lyza et vecaskyod. Decy myg ymvorakwem cykleud joy JYD, kly vsooymk dkjmujou teo ymvorakwem, jzemq gwkl ODJ. Vorakeqojalr wd j xjdk twyzu jmu wd xyor wmkyoydkwmq klesql. De iwvi bjvi, oyju sa em decy veez vwalyod jmu ljxy tsm!

El jmu teo reso oyveoud cr mjcy wd WvyVKT{jzgjrd_zwdkym_ke_reso_dsbdkwksky_tzjqd}.


=== Decoded data ===
Hi!

Welcome to IceCTF!

I'll be your substitute flag for the day. For today, we are studying basic cryptography and its applications. Cryptography has a long history, although with the advent of computers it has gotten really complicated. Some simple old ciphers are the Caesar cipher, the Vigenere cipher, the substitution cipher, which is this one, and so on. Almost all of these ciphers are easily broken today with the help of computers. Some new encryption methods are AES, the current standard for encryption, along with RSA. Cryptography is a vast field and is very interesting though. So kick back, read up on some cool ciphers and have fun!

Oh and for your records my name is IceCTF{always_listen_to_your_substitute_flags}.
Share