2016-11-19

RC3 CTF 2016: Salad - Crypto 100

I thought I'd start off light in this CTF, and so I picked this challenge as it was the lowest point challenge in the Crypto category. The flavor text for the challenge was:

Salad
100

"The fault, dear Brutus, is not in our stars, but in ourselves." (I.ii.141) Julius Caesar in William Shakespeare's Julius Caesar

Cipher Text: 7sj-ighm-742q3w4t

If the challenge title wasn't enough of a hint, they go ahead and mention Caesar's name twice in the quote line. I had a strong feeling that this would be a simple Caesar or rot (rotation) cipher. Looking at the ciphertext though we see numbers interspersed throughout which isn't usual for a simple rotation cipher (which normally acts on the alphabet, a-z).

My first instinct is to tack on 0-9 to the end of the alphabet and then rotate through all 35 permutations to see if the solution was contained therein:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python3

alpha = 'abcdefghijklmnopqrstuvwxyz'
num = '0123456789'
alnum = alpha + num

ctext = '7sj-ighm-742q3w4t'

def rotate(s, num):
    new1 = ''
    for c in s:
        if c in alnum:
            new1 += alnum[(alnum.index(c) + num) % 36]
        else:
            new1 += c

    return new1


for x in range(36):
    print("{}".format(rotate(ctext, x)))

And Lo and Behold:

7sj-ighm-742q3w4t
8tk-jhin-853r4x5u
9ul-kijo-964s5y6v
avm-ljkp-a75t6z7w
bwn-mklq-b86u708x
cxo-nlmr-c97v819y
dyp-omns-da8w92az
ezq-pnot-eb9xa3b0
f0r-qopu-fcayb4c1
g1s-rpqv-gdbzc5d2
h2t-sqrw-hec0d6e3
i3u-trsx-ifd1e7f4
j4v-usty-jge2f8g5
k5w-vtuz-khf3g9h6
l6x-wuv0-lig4hai7
m7y-xvw1-mjh5ibj8
n8z-ywx2-nki6jck9
o90-zxy3-olj7kdla
pa1-0yz4-pmk8lemb
qb2-1z05-qnl9mfnc
rc3-2016-romangod
sd4-3127-spnbohpe
te5-4238-tqocpiqf
uf6-5349-urpdqjrg
vg7-645a-vsqerksh
wh8-756b-wtrfslti
xi9-867c-xusgtmuj
yja-978d-yvthunvk
zkb-a89e-zwuivowl
0lc-b9af-0xvjwpxm
1md-cabg-1ywkxqyn
2ne-dbch-2zxlyrzo
3of-ecdi-30ymzs0p
4pg-fdej-41zn0t1q
5qh-gefk-520o1u2r
6ri-hfgl-631p2v3s