import socket

HOST = "torang-munara.my.id"
PORTS = (22, 23, 5364)

for port in PORTS:
    try:
        with socket.create_connection((HOST, port), timeout=4) as sock:
            sock.settimeout(3)
            data = sock.recv(64)
        if data.startswith(b"SSH-"):
            status = "ssh_banner"
        elif data.startswith(b"\xff"):
            status = "telnet_negotiation"
        elif data:
            status = "non_ssh_service"
        else:
            status = "open_no_banner"
    except (OSError, socket.timeout):
        status = "unreachable"
    print(f"port={port}|{status}")
