-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchal22.py
More file actions
executable file
·32 lines (23 loc) · 868 Bytes
/
chal22.py
File metadata and controls
executable file
·32 lines (23 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
# chal22.py - MT19937 seed
#
# Copyright (C) 2015 Andrew J. Zimolzak <andyzimolzak@gmail.com>,
# and licensed under GNU GPL version 3. Full notice is found in
# the file 'LICENSE' in the same directory as this file.
from cryptopals import warn
from myrand import MTRNG, find_time_seed
import time
import random
#### Generate a number from RNG seeded with time
time.sleep(random.randint(7,15)) # 40,1000 is more fun though
r = MTRNG(int(time.time()))
time.sleep(random.randint(7,15))
target_num = r.extract_number()
#### Reverse engineer the seed
print "Received target of:", target_num
found_seed = find_time_seed(target_num, int(time.time()))
print "Seed used was:", found_seed
print "In other words,", time.ctime(found_seed)
#### tests, if any ####
assert(found_seed > 1441224144)
warn("Passed assertions:", __file__)