From ec8893a097a6c0fffebd7db9e4a5568a3bf4df47 Mon Sep 17 00:00:00 2001 From: jerome Date: Sun, 12 Oct 2025 17:41:43 +0200 Subject: organisation --- sockets/chat_client.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 sockets/chat_client.py (limited to 'sockets/chat_client.py') diff --git a/sockets/chat_client.py b/sockets/chat_client.py new file mode 100644 index 0000000..affc1d3 --- /dev/null +++ b/sockets/chat_client.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import sys,socket,os + +def chat_client(host,port): + whoami = os.getenv("USER") + try: + s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) + s.connect((host,port)) + while True: + message = input("moi > ") + message = whoami+" > "+message # à commenter pour le bindshell + s.sendall(message.encode()) + data = s.recv(1024) + print(data.decode().strip()) + except KeyboardInterrupt: + s.close() + finally: + print("bye") + +if __name__ == "__main__": + try: + chat_client(sys.argv[1],int(sys.argv[2])) + except IndexError: + print(f"{sys.argv[0]} demande un hôte où se connecter et un numéro de port") + -- cgit v1.2.3