Sonic
[crypto]
Sonic
Gotta go fast
- URL:
nc chal.tuctf.com 30100
Recon
Shift cipher, just gotta code it. Turns out, not really needed, only one challenge is given.
Code
words_dictionary.json
is from here.
from pwn import *
import sys
import json
import string
# Copy-paste from https://eddmann.com/posts/implementing-rot13-and-rot-n-caesar-ciphers-in-python/
def rot_alpha(n):
from string import ascii_lowercase as lc, ascii_uppercase as uc
lookup = string.maketrans(lc + uc, lc[n:] + lc[:n] + uc[n:] + uc[:n])
return lambda s: s.translate(lookup)
with open('words_dictionary.json', 'r') as fs:
words = json.load(fs)
rots = { k: rot_alpha(k) for k in range(26) }
def solve(s):
for i in range(26):
x = rots[i](s)
print(x)
# deal with plurals and shit.
if x.lower() in words or x.lower() + 's' in words:
return x
return None
c = remote("chal.tuctf.com", 30100)
while True:
r = c.readuntil("\n")
if "Hey, decode this:" in r:
s = r.strip("\n").split(": ")[1]
if not r.startswith("Hey, decode"):
print("< " + r)
continue
o = solve(s)
print("LINE: " + r)
print("GOT: " + o)
c.send(o + "\n")
c.interactive()