-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolve.py
70 lines (48 loc) · 1.33 KB
/
solve.py
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
59
60
61
62
63
64
65
66
67
68
69
70
from websocket import create_connection
import requests
import base64
import json
import os
from time import time
DELAY = 0.0058
BASE_URL = 'https://kaboot-81851f9a0bdd0f85.tjc.tf'
def recv(ws):
return base64.b64decode(ws.recv()).decode()
def recv_json(ws):
return json.loads(recv(ws))
def send(ws, data):
ws.send(base64.b64encode(data.encode()))
def send_json(ws, data):
send(ws, json.dumps(data))
for i in range(1):
res = requests.post(f'{BASE_URL}/create')
res_url = res.url.split('//')[1]
for i in range(100):
ws = create_connection(f'wss://{res_url}')
recv(ws)
while True:
d = recv_json(ws)
if 'end' in d:
print(d)
break
send_json(ws, {
'id': os.urandom(4).hex(),
'answer': d['answer'],
'send_time': time()
})
res = requests.post(f'{BASE_URL}/create')
res_url = res.url.split('//')[1]
for i in range(100):
ws = create_connection(f'wss://{res_url}')
print(recv(ws))
uuid = os.urandom(4).hex()
while True:
d = recv_json(ws)
if 'end' in d:
print(d)
break
send_json(ws, {
'id': uuid,
'answer': d['answer'],
'send_time': time() + DELAY + i / 10000
})