import ssl import websocket import threading import sys import termios import tty host = "" ws = websocket.create_connection( "wss:///terminal/ws", host=host, origin=f"https://{host}", sslopt={"cert_reqs": ssl.CERT_NONE} ) def recv(): while True: try: data = ws.recv() if data: sys.stdout.write(data) sys.stdout.flush() except: break def main(): old = termios.tcgetattr(sys.stdin) try: tty.setraw(sys.stdin.fileno()) threading.Thread(target=recv, daemon=True).start() while True: ch = sys.stdin.read(1) if ch == "\x04": break ws.send(ch) finally: termios.tcsetattr( sys.stdin, termios.TCSADRAIN, old ) ws.close() if __name__ == "__main__": print("[+] connected") main()