Here’s a README.md file for basic_port_scanner.py project:
The Basic Port Scanner is a Python script that allows users to scan a range of ports on a target host to determine which ports are open. It uses Python's built-in socket library for TCP connection attempts and is a foundational tool for learning about network security and reconnaissance.
- Scan a range of ports on a specified target.
- Identify open TCP ports quickly.
- Lightweight and easy to use.
- Customizable to include additional features like multi-threading or scanning multiple hosts.
- Python 3.x
- No additional libraries are required (uses the built-in
socketlibrary).
-
Clone the repository or copy the
basic_port_scanner.pyscript to your local machine. -
Run the script using Python:
python basic_port_scanner.py 3. Input the required details when prompted: • Target IP: The IP address of the host you want to scan. • Port Range: Specify the range of ports to scan (e.g., 1-1000).
Example input:
Enter target IP address: 192.168.1.1 Enter start port: 1 Enter end port: 1000
4. View the results. The script will output a list of open ports on the target host.
Example Output
Scanning 192.168.1.1 for open ports between 1 and 1000...
Port 22 is open (SSH) Port 80 is open (HTTP) Port 443 is open (HTTPS)
Scan completed in 10.32 seconds.
Code Overview
• Socket Connections: The script attempts to connect to each port using the socket library.
• Error Handling: Handles connection errors gracefully, allowing for uninterrupted scans.
• Performance: Single-threaded by default; can be extended for faster multi-threaded scanning.
Project Structure
basic_port_scanner/ │ ├── basic_port_scanner.py # Main Python script for port scanning └── README.md # Documentation file
Limitations
• Speed: The script is single-threaded, which can be slow for large port ranges.
• TCP Only: Scans only for open TCP ports; does not detect UDP services.
• Permissions: Requires administrative privileges on some systems to scan certain ports.
Possible Enhancements
• Add multi-threading for faster scans.
• Include UDP scanning capabilities.
• Output results to a file for further analysis.
• Add service detection (e.g., using banner grabbing).
Legal Disclaimer
This tool is intended for educational purposes only. Please ensure you have permission from the target system’s owner before running this script. Unauthorized scanning of networks is illegal and unethical.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Ani Chigozie Destiny Cybersecurity Enthusiast & Developer
Feel free to contribute or create issues if you encounter any bugs or have suggestions for improvement.
- Replace
LICENSEwith the actual license file you include in your project. - Add a link to the script repository on GitHub if applicable.
- Update features or instructions based on any additional functionality in your script.