Skip to content

jglueck21/PortScanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

9 Commits
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ” Python Port Scanner

A simple but effective Python-based port scanner that detects open TCP ports on a host.
Inspired by tools like Nmap, this project demonstrates the fundamentals of network enumeration and cybersecurity.


๐Ÿš€ Features

  • Multi-threaded scanning for faster results
  • Detects open TCP ports in a given range
  • Maps ports to common services (e.g., 22 โ†’ ssh, 3306 โ†’ mysql)
  • Built-in timeout handling (avoids freezing on closed/filtered ports)
  • Tested safely on:
    • Localhost
    • Docker containers (e.g., MariaDB on port 3306)
    • Public test host scanme.nmap.org

๐Ÿ“– How It Works

The scanner uses Pythonโ€™s built-in socket module to:

  1. Create a TCP socket for each port
  2. Attempt a connection to the target host and port
  3. Return open if the connection succeeds within a given timeout
  4. Look up the associated service name (if available)

Concurrency is handled using Pythonโ€™s threading library, allowing multiple ports to be scanned simultaneously.


๐Ÿ’ป Usage

1. Run the script

python3 scanner.py <start_port> <end_port>

2. Example (scan MariaDB container on port 3306)

python3 scanner.py localhost 3300 3400

Output: ๐Ÿ” Scanning localhost from port 3300 to 3400...

[+] Port 3306 is open (mysql)

โœ… Scan complete!

3. Example (scan public test host)

python3 scanner.py scanme.nmap.org 20 1000


๐Ÿ›ก๏ธ Safe Testing

โš ๏ธ Always scan only:

  • Your own machine (localhost)
  • Local test environments (e.g., Docker containers)
  • Approved test servers like scanme.nmap.org

Never scan random websites or servers without explicit permission.


๐ŸŽ“ Skills Learned

  • Networking fundamentals (TCP/IP, ports, sockets)
  • Writing Python scripts with error handling and timeouts
  • Using threads for concurrent execution
  • Safe penetration testing practices using controlled environments

๐Ÿ”ฎ Possible Future Updates

  • Add process lookup to show which program is bound to an open port
  • Implement UDP scanning in addition to TCP
  • Add an option for output reports (JSON, CSV, HTML)
  • Include a progress bar / fancy CLI UI for better user experience
  • Compare results automatically with nmap for validation

๐Ÿ“ธ Demo Screenshot

image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages