-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathagentServer.py
74 lines (56 loc) · 1.96 KB
/
agentServer.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
71
72
73
74
import socket
import pickle , json
import threading
import os
class Server(threading.Thread):
def __init__(self, hs,c):
threading.Thread.__init__(self)
def run(self):
self.message = "Okey"
while True:
try:
self.data = c.recv(1024)
self.data = json.loads(self.data.decode("utf-8"))
hostname = self.data.get("hostname")
ipadress = self.data.get("ipadress")
opentime = self.data.get("time")
platform = self.data.get("platform") # Two Key ([Windows10,32bit])
username = self.data.get("username")
for host in hostname:
HOSTNAME.append(host)
for user in username:
USERNAME.append(user)
for ip in ipadress:
IPADRESS.append(ip)
for optime in opentime:
TIME.append(optime)
for plat in platform:
PLATFORM.append(plat)
# HOSTNAME.append(hostname)
# IPADRESS.append(ipadress)
# PLATFORM.append(platform)
# USERNAME.append(username)
# TIME.append(opentime)
with open(os.getcwd()+'\\dist\\a.txt','w') as h:
h.write(HOSTNAME)
print(HOSTNAME,IPADRESS,TIME,PLATFORM,USERNAME)
except:
break
c.close()
host = NONE
port = 4444
_ = []
HOSTNAME = []
IPADRESS = []
TIME = []
PLATFORM = []
USERNAME = []
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((host, port))
while True:
s.listen(400)
c, hs = s.accept()
thread = Server(hs,c)
thread.daemon = True
thread.start()