A minimal TCP port scanner written in Go.
pscanner -h <host> -p <ports>
| Flag | Description |
|---|---|
-h |
Target host (hostname or IP) |
-p |
Port specification (see formats below) |
| Format | Example | Description |
|---|---|---|
| Single | 80 |
One port |
| List | 80,443,8080 |
Comma-separated ports |
| Range | 8000-8080 |
Inclusive range |
| Mixed | 22,80,8000-8080 |
Any combination |
# Single port
pscanner -h example.com -p 80
# Common web ports
pscanner -h 192.168.1.1 -p 80,443,8080,8443
# Port range
pscanner -h 10.0.0.1 -p 1-1024
# Mixed
pscanner -h example.com -p 22,80,443,8000-9000Each non-closed port is logged with its state:
- Open — connection accepted
- Filtered — connection timed out (firewall likely present)
Closed ports are suppressed. A summary line shows total ports scanned and elapsed time.
2026/06/27 12:00:00 Scanned 1024 ports in 3.42 seconds
2026/06/27 12:00:00 Port 22 Open
2026/06/27 12:00:00 Port 80 Open
2026/06/27 12:00:00 Port 443 Open
cd src
go build -o pscanner scanner.go