Skip to content

NYXBAM/port-scanner-cli-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CLI Port Scanner

A simple and efficient command-line port scanner written in Python. This tool supports both TCP Connect and SYN (stealth) scanning methods to identify open ports on a target host. Ideal for network administrators and security enthusiasts to perform basic network reconnaissance.


πŸš€ Features

  • πŸ” Dual Scan Modes: Choose between TCP Connect and SYN scanning
  • 🎯 Customizable Port Range: Specify any port range (1–65535)
  • πŸ›‘οΈ Error Handling: Robust handling of invalid inputs, network errors, and user interruptions
  • πŸ“‹ Clean Output: Displays open ports and timestamps in a readable format
  • ⚑ Lightweight: Minimal dependencies, fast to install and run

βœ… Requirements

  • Python 3.6+
  • scapy library (required for SYN scanning)
  • Root privileges (required for SYN scanning)

πŸ“¦ Installation

  1. Clone the repository:

    git clone https://github.com/NYXBAM/cli-port-scanner.git
    cd cli-port-scanner
    pip install -r requirements.txt
  2. Usage

    python3 portscanner.py <host> <start_port> <end_port> <syn_scan>

    Arguments

    host: Target IP address or hostname (e.g., 127.0.0.1 or example.com)

    start_port: Starting port number (1–65535)

    end_port: Ending port number (1–65535)

    syn_scan: Scanning mode β€” use yes for SYN scan, no for TCP Connect scan

πŸ”§ Examples:

Scan ports 20–80 on localhost using TCP Connect:

python3 portscanner.py 127.0.0.1 20 80 no

Scan ports 20–80 on a remote host using SYN scan (requires root):

sudo python3 portscanner.py example.com 20 80 yes

πŸ–₯️ Sample Output:

Scanning host: 127.0.0.1
Scan started at: 2025-07-12 16:45:23.123456
--------------------------------------------------
Port 22: Open
Port 80: Open
--------------------------------------------------
Open ports: [22, 80]
Scan completed at: 2025-07-12 16:45:25.789012

⚠️ Notes

SYN Scanning: Requires root privileges due to raw socket usage. Run with sudo when using --syn-scan yes.

Legal Warning: Port scanning without proper authorization may be illegal. Use this tool only on systems you own or are authorized to scan.

Performance: This is a single-threaded scanner for simplicity. For faster scanning, consider adding multithreading in future versions.

🀝 Contributing

Contributions are welcome! Please open an issue or submit a pull request for bugs, features, or suggestions. πŸ“„ License

This project is licensed under the MIT License.

About

A simple and efficient command-line port scanner written in Python.

Topics

Resources

Stars

Watchers

Forks

Languages