A simple port scanning tool written in Python that allows users to scan TCP and UDP ports on a specified IP address. The tool provides a command-line interface for easy interaction.
- TCP Port Scanning: Scan a range of TCP ports on a target IP address.
- UDP Port Scanning: Scan a range of UDP ports on a target IP address.
- Interactive Menu: User-friendly menu to select scanning options.
- Input Validation: Ensures valid IP addresses and port ranges are provided.
- Display Open Ports: Shows a list of open ports found during scanning.
- Change Target IP: Allows changing the target IP address without restarting the application.
- Python 3.x
- Standard Python libraries:
socket
git clone https://github.com/Rskladanek/PortScanner.git
cd PortScanner
PortScanner/
├── main.py
├── menu.py
└── modules/
└── portscanner.py
No external dependencies are required beyond the Python Standard Library.
Execute the main script using Python:
python main.py
Upon running the application, you'll be greeted with an ASCII art banner and prompted to enter the target IP address. After entering a valid IP address, the main menu will be displayed:
=== Choose an Option ===
1. TCP Port Scan
2. UDP Port Scan
3. Show Open Ports
4. Change Target IP
5. Exit
=========================
Option Details:
TCP Port Scan
Prompts for a starting and ending port number.
Scans the specified range for open TCP ports.
Displays progress and results.
UDP Port Scan
Prompts for a starting and ending port number.
Scans the specified range for open UDP ports.
Due to the nature of UDP, results may vary.
Displays progress and results.
Show Open Ports
Displays a list of open ports found during the current session.
Separates TCP and UDP ports for clarity.
Change Target IP
Allows you to change the target IP address without restarting the application.
Validates the new IP address before accepting it.
Exit
Exits the application gracefully.
The entry point of the application. It imports the Menu class from menu.py and starts the menu loop.
from menu import Menu
if __name__ == "__main__":
m = Menu()
m.run()
Contains the Menu class, which handles user interaction, displays options, and processes user input.
from modules.portscanner import PortScanner
class Menu: # Class implementation...
Contains the PortScanner class, which performs the actual scanning of TCP and UDP ports.
import socket
class PortScanner: # Class implementation...
UDP Scanning Reliability
UDP scanning is inherently less reliable due to the protocol's connectionless nature.
Many UDP services do not respond to unsolicited packets, making it difficult to determine if a port is open or filtered.
Scanning UDP ports may produce false negatives.
Performance
Scanning large port ranges can be time-consuming, especially for UDP scans.
The tool currently scans ports sequentially without multithreading.
Permission Requirements
Scanning certain ports or running on specific systems may require administrative privileges.
Ensure you have the necessary permissions to execute the scans.
This tool is intended for educational purposes and authorized network testing only.
Scanning ports on networks or devices without explicit permission from the owner is illegal and unethical.
The author is not responsible for any misuse of this tool.
This project is licensed under the MIT License.