Skip to content

Instantly share code, notes, and snippets.

@dkales dkales/attack.py Secret
Created Feb 23, 2016

Embed
What would you like to do?
Hashdesigner Internetwache CTF challenge crypto70
#!/usr/bin/python2
from pwn import *
import random
def proof_of_work(prefix, rlen=15, hashfunc=hashlib.sha1):
i = 0
maxiter = 2 ** 28
while i < maxiter:
i += 1
s = prefix
for _ in range(rlen-len(s)):
s += random.choice(string.lowercase+string.digits)
h = hashfunc()
h.update(s)
digest = h.digest()
binary = ''.join('{0:08b}'.format(ord(x)) for x in digest)
if binary.endswith("0"*16):
log.info("found proof of work after {} iterations"
.format(i))
return s
log.critical("couldn't find matching proof of work after {} iterations"
.format(i))
return None
p = remote("188.166.133.53", 10009)
line = p.recvline()
prefix = line[line.find("It has ")+7:line.find(" as the prefix.")]
proof = proof_of_work(prefix)
p.recv(len("Enter work:"))
p.sendline(proof)
succ = p.recvline()
assert("Thank you" in succ)
p.sendline("DhvxGXEdJkRiv4QEDS") # brute-forced offline
p.interactive()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.