I was practicing a small program in socket
that allows access to the shell
of the server machine. The case is that the p r
int that would have to be sent to the client (which is the answer of os.system()
) are numeric (for example the clear
is 0.
Does anyone know why or the solution?
The client code:
import socket
s = socket.socket(socket.AF_INET , socket.SOCK_STREAM)
try:
s.connect(("192.168.43.241" , 4004))
print "conexion establecida"
while True:
mensaje = raw_input(">>")
s.send(mensaje)
print s.recv(1024)
except KeyboardInterrupt:
exit()
the server code:
import socket
print "INICANDO SERVIDOR..."
s = socket.socket(socket.AF_INET , socket.SOCK_STREAM)
try:
s.bind(("192.168.43.241" , 4004))
s.listen(5)
sockets , data = s.accept()
print str("conexion establecida")
while True:
mensaje = socket.recv(1024)
try:
comando = os.system(mensaje)
except:
socket.send("Comando invalido")
socket.send(comando)
except KeyboardInterrupt:
exit()