Skip to content

Instantly share code, notes, and snippets.

@WinMin

WinMin/solve.py Secret

Last active January 27, 2024 13:06
Show Gist options
  • Save WinMin/b93c7ee59a7bd0c7f2ed4aa5eed7e2d6 to your computer and use it in GitHub Desktop.
Save WinMin/b93c7ee59a7bd0c7f2ed4aa5eed7e2d6 to your computer and use it in GitHub Desktop.
rwctf challenge Proof of work (PoW) solve script
#!/usr/bin/env python3
from pwnlib.util.iters import mbruteforce
from hashlib import sha256
import string
import sys
"""
$ ncat -v [HOST] [PORT]
sha256("KOcNc"+"?") starts with 26bits of zero:
usage: $ python3 solve.py KOcNc
"""
prefixes = sys.argv[1]
def brute(cur):
content = prefixes + str(cur)
s = sha256(content.encode())
if s.hexdigest().startswith("000000") and int(s.hexdigest()[6:8], 16) < 0x40:
return True
return False
import pwn
res = mbruteforce(brute, string.ascii_lowercase + string.digits, method = 'upto', length=6, threads = 20)
print(res)
@Gr-1m
Copy link

Gr-1m commented Jan 27, 2024

rw666

@5ime
Copy link

5ime commented Jan 27, 2024

???

@ML-hacker
Copy link

?????

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment