3DSCTF 2016 : crypto100-hotsun

Surfing in the Shallowweb, we have discovered a new algorithm that promises to be the newest substituition cipher. The algorithm to encrypt works as following: the user informs the text to be encrypted and a number N. Initially, the algorithm shift all letters one position to the right (e.g. 'A' tuns into 'B'). With this result, in the next step, the algorithm now shift the text two positions to the right. And with the text from the previous output, it repeats the shift procedure until N. Your task is quite simple: given an encrypted flag and an N number, discover the flag.
Encrypted flag: 3RG{hv1g_f0h_1g_b0h_g0_V0h}
N: 11

Solved by 12 Teams Created by @j3r3mias

Solution

Well, the chall's desc mention a cipher that shift all letters one position, e.g: A->B until N, and N=11..
This is known as ROT(n)/Caesar cipher, let's try my Caesar script:

## Caesar script used in crypto100-hotsun @ 3dsctf-2k16
# @author intrd - http://dann.com.br/
# @license Creative Commons Attribution-ShareAlike 4.0 International License - http://creativecommons.org/licenses/by-sa/4.0/
import base64, string
def int_caesar(ch, shift):
n = ord(ch)
if ord('a') <= n <= ord('z'):
n = n - ord('a')
n = (n + shift) % 26
n = n + ord('a')
return chr(n)
elif ord('A') <= n <= ord('Z'):
n = n - ord('A')
n = (n + shift) % 26
n = n + ord('A')
return chr(n)
else:
return ch
def intCaesar(s, shift):
return ''.join(int_caesar(ch, shift) for ch in s)
# Usage
# flag="3RG{hv1g_f0h_1g_b0h_g0_V0h}"
# flag="Toik! Znk Igkygx iovnkx, gryu qtuct gy g ynolz iovnkx, oy utk ul znk yosvrkyz luxsy ul ktixevzout. Tuc, utk rgyz wakyzout..."
# for x in range(1, 40):
# try:
# print x
# print "shift: "+str(x)+" "+caesar(flag,x)
# except Exception as e:
# print e
view raw int_caesar.py hosted with ❤ by GitHub

bam!

flag: 3DS{CENSORED}

Note: Why i ROTed 1 to 40 if the tip says N=11? Always u use caesar, try to ROT more than tip says.. and do some visual spection looking for the flag, these motherfuckrs love fake tips.