Back to Browse

pico2025 Chronohack

1.4K views
May 21, 2025
5:08

Using the time to seed a random number generator is insecure because the time is known. import random import time from pwn import * def get_random(length,seed): alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" random.seed(seed) # seeding with current time s = "" for i in range(length): s += random.choice(alphabet) return s def main(): print("Welcome to the token generation challenge!") token_length = 20 # the token length offset=0 while (1): seed = int(time.time()*1000+offset) r=remote("verbal-sleep.picoctf.net", 62036) token = get_random(token_length,seed) n=0 while n != 50: try: user_guess = r.recvuntil(b"Enter your guess for the token (or exit):") r.sendline(token) print(offset,n,token) ans=(r.recvline()) if b"Congratulations" in ans: print(ans) ans=(r.recvline()) print(ans) return print(ans) seed = seed+1 token = get_random(token_length,seed) n+=1 except KeyboardInterrupt: print("\nKeyboard interrupt detected. Exiting the program...") offset=offset+40 if __name__ == "__main__": main()

Download

0 formats

No download links available.

pico2025 Chronohack | NatokHD