← All labs

Python Port Scanner

A small multi-threaded TCP port scanner written to understand how tools like Nmap work.

complete · 10 Jun 2026

Pythonsocketsthreading

Placeholder project — replace with your own.

import socket

def scan(host: str, port: int) -> bool:
    with socket.socket() as s:
        s.settimeout(0.5)
        return s.connect_ex((host, port)) == 0

Only scan systems you own or have permission to test.