Viewing a single comment thread. View all comments

ykssapsspassky t1_j1hjdg7 wrote

From chat gpt:

import socket

def port_scan(host, port): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(0.5) result = sock.connect_ex((host, port)) if result == 0: print(f"Port {port} is open") sock.close()

for port in range(1, 1024): port_scan("localhost", port)

1