返回首页 Port scanning script

Port scanning script

**Scripts | 2025-06-18 04:16:57

import socket
from concurrent.futures import ThreadPoolExecutor

def scan_port(ip, port):
    try:
        with socket.socket() as s:
            s.settimeout(1)
            s.connect((ip, port))
            print(f"{ip}:{port} 开放")
    except:
        pass

ports = [21, 22, 80, 443, 3389]
with ThreadPoolExecutor(50) as executor:
    for port in ports:
        executor.submit(scan_port, "target_ip", port)