-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (38 loc) · 1.44 KB
/
Copy pathmain.py
File metadata and controls
43 lines (38 loc) · 1.44 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
import websocket, json, requests, traceback
CLIENT_ID = "123"
CLIENT_SECRET = "123"
HTTP_URL = "http://173.82.136.177:4376"
class myWebSocket:
def __init__(self, client_id, client_secret, client_url="wss://socket.xzynb.top/ws"):
self.ws = websocket.WebSocket()
self.ws.connect(client_url)
self.client_id = client_id
self.client_secret = client_secret
self.client_url = client_url
self.send("init")
def send(self, type, data={}, flag="flag"):
params = {
"type": type,
"data": data,
"client_id": self.client_id,
"client_secret": self.client_secret,
"flag": flag
}
self.ws.send(json.dumps(params))
def recv(self, echo=None):
return json.loads(self.ws.recv())
if __name__ == "__main__":
ws = myWebSocket(CLIENT_ID, CLIENT_SECRET)
while True:
recv = ws.recv()
print(recv)
try:
if recv.get("type") == "execute":
name = recv.get("data").get("name")
params = recv.get("data").get("params")
data = requests.post(f"{HTTP_URL}/{name}", params).json()
data['flag'] = recv.get("flag")
ws.send("return", data, recv.get("flag"))
except Exception as e:
print("There is an error:"+str(e))
ws.send("error", {"msg":str(e),"detail":traceback.format_exc()}, recv.get("flag"))