Skip to content

Instantly share code, notes, and snippets.

@st98
Created August 12, 2019 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save st98/00a53f1289058c5f7443ba4352501243 to your computer and use it in GitHub Desktop.
Save st98/00a53f1289058c5f7443ba4352501243 to your computer and use it in GitHub Desktop.
InterKosenCTF - pascal homomorphicity
from pwn import *
s = remote('crypto.kosenctf.com', 8002)
s.recvline()
encrypted = int(s.recvline())
s.recvline()
table = ''.join(sorted('{}abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_- !?#'))
l = 48
known = 'KosenCTF{'
for _ in range(len(known), l):
p = ''
for c in table:
temp = int((known + c).ljust(l, '\0').encode('hex'), 16)
s.recvuntil('> ')
s.sendline(str(temp))
s.recvline()
res = int(s.recvline())
if res > encrypted:
known += p
break
p = c
print known
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment