Port Scanner
Lightweight TCP port scanner for Linux
Loading...
Searching...
No Matches
Port Scanner

A simple TCP port scanner written in C++ to check the accessibility of ports on remote IPv4 and IPv6 hosts.

Features

  • Check availability of one or multiple TCP ports on an IPv4/IPv6 address
  • Uses POSIX sockets and system calls
  • Works only on Linux systems
  • Built with CMake and C++26 standard

Installation (Fedora / RHEL-based)

This package is available via Fedora Copr:

sudo dnf copr enable artjom-fedosov/port-scanner
sudo dnf install port-scanner

Manual Build

git clone https://github.com/artyom-fedosov/port-scanner.git
cd port-scanner
./scripts/install.sh

or

git clone https://github.com/artyom-fedosov/port-scanner.git && cd port-scanner && ./scripts/install.sh

Requirements

  • Linux operating system
  • C++26 compatible compiler
  • CMake version 3.16 or higher

Documentation

Online documentation

To generate the documentation locally, run:

doxygen Doxyfile

The generated HTML documentation will be available in the docs/html directory.

Usage

Run the port scanner by specifying an IP address (IPv4 or IPv6) followed by one or more ports to check:

$ port-scanner 192.168.8.1 22 80 443
22 is accessible
80 is not accessible
443 is accessible

Note: In the terminal, accessible ports are displayed in green, while inaccessible ports are shown in red for better readability. The order of the port scan results may vary because the checks are performed concurrently using threads.

You can also scan a range of ports using shell brace expansion (bash):

$ port-scanner 192.168.8.1 {0..65535} | grep "is accessible"

Testing

This project uses CTest for running unit tests and integrates Valgrind Memcheck to detect memory errors and leaks.

To run the tests, use:

cd build
ctest

To run the tests and see detailed output of any failures:

cd build
ctest --output-on-failure

License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.