-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsolve.py
More file actions
58 lines (35 loc) · 1.04 KB
/
solve.py
File metadata and controls
58 lines (35 loc) · 1.04 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from pwn import random, re, remote, sys, time
def main():
ip, port = sys.argv[1].split(':')
flag = win_lotto(ip, port)
print()
print(flag)
def win_lotto(ip, port):
r = remote(ip, port)
now = int(time.time()) - 2
out = r.recvuntil(b'numbers: ').decode()
extraction, _ = re.findall(r'EXTRACTION: ((\d+ ){5})', out)[0]
ext, dt = '', 0
while ext != extraction.strip():
ext, sol = handle(now + dt)
dt += 1
if dt > 10:
print('Not found...')
sys.exit(1)
r.sendline(sol.encode())
flag = re.findall(r'HTB\{.*?\}', r.recvall().decode('utf-8'))[0]
r.close()
return flag
def handle(seed):
random.seed(seed)
def gen():
numbers = []
while len(numbers) < 5:
r = random.randint(1, 90)
if r not in numbers:
numbers.append(r)
return numbers
extracted, solution = gen(), gen()
return ' '.join(map(str, extracted)), ' '.join(map(str, solution))
if __name__ == '__main__':
main()