Skip to content

Instantly share code, notes, and snippets.

@hvnsweeting
Created October 5, 2021 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hvnsweeting/619ecf04aa9b57bd6b44f3fcc57fe8c2 to your computer and use it in GitHub Desktop.
Save hvnsweeting/619ecf04aa9b57bd6b44f3fcc57fe8c2 to your computer and use it in GitHub Desktop.
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