A simple, fast, and educational port scanner built in Python. This tool uses multithreading to efficiently scan a range of TCP and UDP ports on a given host.
- TCP Scanning: Quickly identify open TCP ports on a target.
- UDP Scanning: Detect open or filtered UDP ports.
- Multithreaded: Utilizes a thread pool to perform scans concurrently, significantly reducing scan time.
- Modular Design: The code is split into logical files (
main.py,scanner.py,threaded_scanner.py) for clarity and maintainability. - User-friendly Interface: Simple command-line prompts for target IP, port range, and protocol.
Make sure you have Python 3 installed on your system. No external libraries are needed as this project uses Python's built-in socket and threading modules.
-
Clone the Repository (or download the files).
-
Navigate to the project directory in your terminal.
-
Run the script using the following command:
python main.py
-
Follow the prompts:
- Enter the target IP address or hostname (e.g.,
127.0.0.1orscanme.nmap.org). - Enter the port range (e.g.,
1-1024). - Choose the protocol (
tcporudp).
- Enter the target IP address or hostname (e.g.,
The scanner will then report all open ports it finds.
main.py: The entry point of the application. Handles all user interaction and orchestrates the scanning process.scanner.py: Contains the core logic for scanning a single port. Thescan_portfunction uses Python'ssocketmodule for both TCP and UDP checks.threaded_scanner.py: Manages the multithreading. It uses aQueueto distribute ports to a pool of worker threads, making the scan much faster.README.md: This file.
The project includes a comprehensive test suite to ensure functionality and prevent regressions.
From the project's root directory, run the following command:
python -m unittest test_scanner.py