-
-
Notifications
You must be signed in to change notification settings - Fork 89
Simple Port Scanner
CarterPerez-dev edited this page Feb 11, 2026
·
1 revision
Concurrent TCP port scanner written in C++ with async I/O and banner grabbing.
A high-performance TCP port scanner using Boost.Asio for asynchronous I/O. Probes target hosts to identify open, closed, and filtered ports with concurrent scanning of hundreds of ports simultaneously. Includes service banner grabbing for fingerprinting.
Status: Complete | Difficulty: Beginner
This tool is for authorized security testing only. Only scan systems you own or have explicit written permission to test. Unauthorized port scanning may be illegal.
| Technology | Version | Purpose |
|---|---|---|
| C++ | C++20 | Core language |
| Boost.Asio | - | Async network I/O |
| Boost.Program_options | - | CLI argument parsing |
| CMake | 3.31+ | Build system |
- Concurrent TCP connect scanning
- Configurable thread count (default 100)
- Port range and list support (e.g.,
1-1024or80,443,8080) - Three port state detection: OPEN, CLOSED, FILTERED
- Service banner grabbing for fingerprinting
- Configurable connection timeout
| State | Meaning | TCP Response |
|---|---|---|
| OPEN | Service listening | SYN-ACK received |
| CLOSED | Nothing listening, host responded | RST received |
| FILTERED | Firewall dropped packets silently | Timeout (no response) |
- First step in penetration testing reconnaissance
- Attack surface mapping for security audits
- Detecting unauthorized services and backdoors
- Understanding TCP handshake mechanics
main.cpp (CLI parsing with boost::program_options)
↓
┌─────────────────────────────────────────────┐
│ PortScanner Class │
│ │
│ ┌─────────────────────────────────────┐ │
│ │ Boost.Asio io_context │ │
│ │ Thread pool (configurable count) │ │
│ └──────────────────┬──────────────────┘ │
│ │ │
│ ┌──────────────────▼──────────────────┐ │
│ │ Async TCP Connect per port │ │
│ │ - Connect attempt with timeout │ │
│ │ - State detection (open/closed/ │ │
│ │ filtered) │ │
│ │ - Banner grab on success │ │
│ └──────────────────┬──────────────────┘ │
│ │ │
│ ┌──────────────────▼──────────────────┐ │
│ │ Results Collection │ │
│ │ Port | State | Service | Banner │ │
│ └─────────────────────────────────────┘ │
└─────────────────────────────────────────────┘
cd PROJECTS/beginner/simple-port-scanner
# Build
mkdir build && cd build
cmake ..
make
# Scan localhost ports 1-1024
./simplePortScanner -i 127.0.0.1 -p 1-1024
# Scan specific ports with custom settings
./simplePortScanner -i scanme.nmap.org -p 80,443,8080 -t 50 -e 3| Flag | Description | Default |
|---|---|---|
-i |
Target IP address | Required |
-p |
Port range or list | Required |
-t |
Thread count | 100 |
-e |
Timeout (seconds) | 3 |
simple-port-scanner/
├── src/
│ ├── PortScanner.hpp # Class definition and method signatures
│ └── PortScanner.cpp # Scanning logic, async operations, banner grabbing
├── main.cpp # Entry point, CLI argument parsing
└── CMakeLists.txt # Build configuration (Boost dependencies)
- CMake 3.31+
- C++20 compiler (GCC 10+, Clang 12+, or MSVC 2019+)
- Boost libraries (
apt install libboost-all-devorbrew install boost)
©AngelaMos | CertGames.com | CarterPerez-dev | 2026