Skip to content

Instantly share code, notes, and snippets.

@intrd
Last active March 3, 2017 06:02
Show Gist options
  • Save intrd/2c19d329885dfee9fc70c38910394a7d to your computer and use it in GitHub Desktop.
Save intrd/2c19d329885dfee9fc70c38910394a7d to your computer and use it in GitHub Desktop.
Caesar script used in crypto100-hotsun @ 3dsctf-2k16
## 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment