-
-
Save dkales/d396c0318d12e93d89fa to your computer and use it in GitHub Desktop.
Hashdesigner Internetwache CTF challenge crypto70
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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