Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/python
import pwn
target = "a?!=-,':_ .%($&/+)!0*#;$!"
soln = {}
p = pwn.remote("neverending.tuctf.com",12345)
while True:
print p.recv()
# p.recvuntil("Give me some text:")
p.send(target+"\n")
p.recvuntil("encrypted is ")
data = p.recvuntil("\n")
print data
delta = ord(data[0]) - ord('a')
print "Delta is %d" % delta
soln = {}
for i in range(1,len(target)):
print "TABLE: %c = %c" % (data[i],target[i])
soln[data[i]] = target[i]
p.recvuntil("What is ")
save = p.recvuntil(" decrypted?").replace(" decrypted?","")
print save
p.recvuntil(":")
out = ""
for s in save:
if s in soln.keys():
c = ord(soln[s])
elif ord(s) - delta < 0x20:
c = ord(s) - delta - 2 + ord('a')
else:
c = ord(s) - delta
out += chr(c)
print out
p.send(out + "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment