-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMasterClient.py
More file actions
38 lines (29 loc) · 898 Bytes
/
MasterClient.py
File metadata and controls
38 lines (29 loc) · 898 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
37
38
#!/usr/bin/env python
import socket
import select
import sys
import time
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
IP_address = '127.0.0.1'
Port = 2004
acc = ['firefox','shutdown','gedit']
while True:
try:
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.connect((IP_address, Port))
while True:
print "Shell> "
sockets_list = [sys.stdin, server]
read_sockets,write_socket, error_socket = select.select(sockets_list,[],[])
for socks in read_sockets:
if socks == server:
raise Exception("NOT VALID")
continue
else:
command = sys.stdin.readline()
server.send(command)
sys.stdout.flush()
except:
time.sleep(10)
continue
server.close()