Update Python Ofensivo - Más ejercicios con conexiones socket

This commit is contained in:
2024-01-11 23:08:41 +01:00
parent f09fa0cbf5
commit 8109c2fe30
4 changed files with 150 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
#!/usr/bin/env python3
import socket
def start_client():
host = 'localhost'
port = 1234
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((host, port))
while True:
msg = input("[+] Introduce un mensaje: ")
s.sendall(msg.encode('utf-8'))
if msg.strip() == 'bye':
break
data = s.recv(1024)
print(f"\n[+] Mensaje del servidor: {data.decode().strip()}")
start_client()