-
-
Save hvnsweeting/619ecf04aa9b57bd6b44f3fcc57fe8c2 to your computer and use it in GitHub Desktop.
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
import random | |
import time | |
import hashlib | |
def find(s): | |
seed = s | |
random.seed(seed, version=2) | |
logs = [] | |
while True: | |
rnd = random.random() | |
hash = hashlib.sha256(str(rnd).encode()).hexdigest() | |
flag = f"SNYK{{{hash}}}" | |
if "5bc" in hash: | |
#with open("./flag", "w") as f: | |
# f.write(flag) | |
break | |
else: | |
logs.append(f"Bad random value: {rnd}") | |
if len(logs) == 1: | |
if logs[0] != 'Bad random value: 0.3719072557403058': | |
return | |
logs.append("Flag created 🎉") | |
return "\n".join(logs).strip() | |
s = round(time.time()) | |
#s = 1632886000 | |
#s = 1631321000 | |
#s = 1631183000 | |
#s = 1624583000 | |
print("Start ", s) | |
def solve(start): | |
s = start | |
stop = start - 10000 | |
while True: | |
logs = find(s) | |
#if s % 1_000 == 0: | |
# print(s) | |
if logs == problog: | |
print("FOUND", s) | |
exit() | |
s = s - 1 | |
if s < stop: | |
return | |
if __name__ == "__main__": | |
problog = open("log.txt").read().strip() | |
first_line = problog.splitlines()[0] | |
print(first_line) | |
from concurrent.futures import ThreadPoolExecutor | |
tpe = ThreadPoolExecutor(max_workers=2000) | |
tpe.map(solve, range(s, 0, -10000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment