A simple TCP Port Scanner built in C++17 for Windows, using Winsock2. Built for learning networking concepts and CTF (Capture The Flag) recon.
- Scans a range of TCP ports on a target IP
- Uses non-blocking sockets with configurable timeout
- Identifies common well-known services (SSH, HTTP, HTTPS, SMB, MySQL, etc.)
- Clean summary output with open ports and scan duration
PortScanner/
├── include/
│ └── Scanner.hpp
├── src/
│ ├── Scanner.cpp
│ └── main.cpp
├── data/
└── README.md
- Windows
- g++ (MinGW) with C++17 support
g++ -std=c++17 -o portscanner src/main.cpp src/Scanner.cpp -I include/ -lws2_32portscanner.exe <IP> <start_port> <end_port> [timeout_ms]portscanner.exe 127.0.0.1 1 1024
portscanner.exe 192.168.1.1 1 1024 200timeout_ms is optional (default: 500ms). Lower it for faster scans.
[*] Target : 127.0.0.1
[*] Range : 1 - 1024
[*] Timeout : 500 ms
[OPEN] Port 135 -> MS-RPC
[OPEN] Port 445 -> SMB
+===========================================+
| SCAN RESULTS SUMMARY |
+===========================================+
| Target : 127.0.0.1 |
| Scanned : 1024 |
| Open : 2 |
+===========================================+
| PORT STATE SERVICE |
+===========================================+
| 135 OPEN MS-RPC |
| 445 OPEN SMB |
+===========================================+
The scanner performs a TCP connect scan on each port in the given range:
- Opens a non-blocking TCP socket
- Attempts to connect to the target IP and port
- Waits for the connection result within the given timeout using
select() - Marks the port as open if the connection succeeds, closed otherwise
This tool is for educational purposes and authorized testing only. Do not scan systems you don't own or don't have explicit permission to test.
MIT