C++17 network port scanner featuring concurrent execution, raw socket scanning techniques, and a Dear ImGui desktop interface.
This project was built primarily to explore and demonstrate practical C++ engineering concepts:
- Low-level socket programming
- Cross-platform networking implementation
- Multithreading and worker synchronization
- Desktop application development with Dear ImGui
- Raw TCP packet construction
- Cross-platform CLI & GUI scanner (Windows & Linux)
- Dear ImGui desktop application (Windows GUI: DirectX 11, Linux GUI: OpenGL 3)
- Layered architecture (Separated scanning engine and GUI)
- Concurrent scanning using a custom thread pool
- TCP Connect scanning
- SYN / FIN / NULL / XMAS raw scans (Linux fully supported; Windows requires Npcap)
- Basic banner grabbing
- CIDR subnet scanning
- JSON / CSV / XML report export
- Scan cancellation token support
- WSAPoll / poll asynchronous I/O multiplexing
The project builds two executables that share the same scanning engine.
graph TD
CLI["port_scanner (CLI)"] --> Engine
GUI["port_scanner_gui"] --> Controller
Controller --> Engine
Engine --> ThreadPool
ThreadPool --> Network["Sockets / WSAPoll / poll"]
Responsible for:
- TCP/UDP scanning
- Raw socket packet construction
- Banner grabbing
- Export pipeline
- Thread pool scheduling
Location:
src/scanner_engine.cpp
Responsible for:
- Launching scan workers
- Progress updates
- Scan cancellation
- Thread synchronization
Location:
src/scan_controller.cpp
Responsible for:
- Dear ImGui rendering
- Interactive scan configuration
- Live console
- Result tables
- Dynamic layouts
Location:
src/gui_view.cpp
| Feature | CLI | GUI |
|---|---|---|
| Windows | ✅ | ✅ |
| Linux | ✅ | ✅ |
| TCP Connect Scan | ✅ | ✅ |
| SYN Scan | ✅ | ✅ |
| FIN Scan | ✅ | ✅ |
| NULL Scan | ✅ | ✅ |
| XMAS Scan | ✅ | ✅ |
| Banner Grabbing | ✅ | ✅ |
| CIDR Scan | ✅ | ✅ |
| JSON Export | ✅ | ✅ |
| CSV Export | ✅ | ✅ |
| XML Export | ✅ | ✅ |
Scanning tasks run on background worker threads so that the interface window continues processing user input and redrawing during scans.
The scanning engine uses mutex locking and atomic counters to safely manage concurrent access across worker threads.
Closing the application during an active scan signals cancellation tokens, waits for worker threads to finish, and releases resources safely.
Platform-specific socket implementations are isolated where possible to support both Winsock and POSIX sockets.
The project keeps third-party dependencies minimal to simplify cross-platform builds:
| Dependency | Purpose | Management / Installation |
|---|---|---|
| Dear ImGui (v1.90.1) | Desktop GUI UI framework | Automatically fetched and compiled via CMake FetchContent |
| SDL2 | Windowing and event handling (Linux GUI) | System package (libsdl2-dev on Ubuntu/Debian) |
| OpenGL 3.3 | Graphics rendering backend (Linux GUI) | System package (libgl1-mesa-dev on Ubuntu/Debian) |
| DirectX 11 & Win32 SDK | Graphics rendering backend (Windows GUI) | Included in Windows SDK / Visual Studio C++ toolchain |
Winsock2 (ws2_32) / POSIX Sockets |
Core network TCP/UDP scanning | Native OS system libraries |
Requirements
- Visual Studio 2019 or newer
- Desktop Development with C++
- CMake
cmake -B build -S .
cmake --build build --config ReleaseGenerated binaries
build/
├── port_scanner.exe
└── port_scanner_gui.exe
Install dependencies
sudo apt update
sudo apt install build-essential cmake git libsdl2-dev libgl1-mesa-devBuild
cmake -B build -S .
cmake --build build -j$(nproc)Note for WSL users working on Windows mounted drives (
/mnt/c,/mnt/d): To avoid NTFS file permission errors, specify a build path inside the Linux filesystem instead:cmake -B ~/build_scanner -S .
Generated binaries
build/
├── port_scanner
└── port_scanner_gui
.\build\port_scanner_gui.exe./build/port_scanner_guiSteps
- Enter an IP address, hostname, or CIDR range.
- Specify target ports.
- Select the scan method.
- Configure thread count.
- Start the scan.
TCP Connect Scan
./build/port_scanner \
-t scanme.nmap.org \
-p 22,80,443 \
-o result.jsonSubnet Scan
./build/port_scanner \
-t 192.168.1.0/24 \
-p 80 \
--threads 200 \
--timeout 500Linux SYN Scan
sudo ./build/port_scanner \
-t 10.0.0.1 \
-p 1-1024 \
-sS \
-o report.csv.
├── assets/
├── include/
├── src/
│ ├── scanner_engine.cpp
│ ├── scan_controller.cpp
│ ├── gui_view.cpp
│ └── ...
├── third_party/
├── CMakeLists.txt
└── README.md
Windows restricts custom TCP packet transmission through raw sockets. True SYN/FIN/NULL/XMAS scans require Npcap. Otherwise, the scanner automatically falls back to TCP Connect mode.
FIN, NULL and XMAS scans rely on RFC 793 behavior. Some operating systems—especially Windows—do not fully implement this behavior, reducing the reliability of these scan techniques.
This project is licensed under the MIT License.
Contributions, issues, and suggestions are welcome.

