Skip to content

Instantly share code, notes, and snippets.


dkales/ Secret

Created Feb 23, 2016
What would you like to do?
Hashdesigner Internetwache CTF challenge crypto70
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()
digest = h.digest()
binary = ''.join('{0:08b}'.format(ord(x)) for x in digest)
if binary.endswith("0"*16):"found proof of work after {} iterations"
return s
log.critical("couldn't find matching proof of work after {} iterations"
return None
p = remote("", 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:"))
succ = p.recvline()
assert("Thank you" in succ)
p.sendline("DhvxGXEdJkRiv4QEDS") # brute-forced offline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment