A powerful and efficient port scanning tool built with Python
This port scanner is designed to efficiently scan multiple IP addresses for open ports using multi-threading capabilities. It provides detailed information about open ports and their associated services, making it a valuable tool for network analysis and security assessment.
$ python port_scanner.py 127.0.0.1
Scanning target: 127.0.0.1
Port 80 is open (HTTP)
Port 3306 is open (MySQL)
Port 5432 is open (PostgreSQL)
Scanning completed in 2.34 seconds
$ python port_scanner.py example.com
Scanning target: example.com (93.184.216.34)
Port 80 is open (HTTP)
Port 443 is open (HTTPS)
Scanning completed in 3.12 seconds
$ python port_scanner.py 192.168.1.1 192.168.1.2 192.168.1.3
Scanning target: 192.168.1.1
Port 80 is open (HTTP)
Port 443 is open (HTTPS)
Scanning target: 192.168.1.2
Port 22 is open (SSH)
Port 3306 is open (MySQL)
Scanning target: 192.168.1.3
Port 27017 is open (MongoDB)
Scanning completed in 5.67 seconds
# Import required libraries
import socket
import termcolor
from socket import gaierror
import sys
import threading
from queue import Queue
import time
def validate_ip(ip):
"""Validate if the given string is a valid IP address"""
try:
socket.inet_aton(ip.strip())
return True
except socket.error:
return False
# ... Rest of the code can be viewed on GitHub ...