This Python script performs a multi-threaded scan on a range of ports for a specified IP address, grabs banners from open ports to identify services, and checks for known exploits using searchsploit
. The program generates a report of the results, including open ports, service banners, and exploitability information, saved to a timestamped file.
- Port Scanning: Scans a specified range of ports to identify open ones.
- Banner Grabbing: Attempts to retrieve service information from open ports.
- Exploitability Check: Uses
searchsploit
to find potential vulnerabilities related to detected services. - Threading for Speed: Scans ports concurrently using multiple threads to reduce scan time.
- Output Report: Saves scan results in a file with a timestamp for easy reference.
-
Clone the repository:
git clone https://github.com/yourusername/port-scanner.git cd port-scanner
-
Install required Python packages:
pip install requests
-
Install
searchsploit
(part of theexploit-db
package):sudo apt update sudo apt install exploitdb
Run the script with the following arguments:
python port_scanner.py <IP_ADDRESS> <START_PORT> <END_PORT>
python port_scanner.py 192.168.1.1 20 1000
The program outputs results both to the console and to a timestamped text file (e.g., bannergrab_01012023_1234.txt
). The report includes:
- IP address and port details
- Service banner or service name
searchsploit
results for potential exploits
The script scans commonly used ports and includes a dictionary of port numbers with typical service names:
COMMON_PORTS = {
21: "ftp", 22: "ssh", 23: "telnet", 25: "smtp",
53: "dns", 80: "http", 110: "pop3", 143: "imap",
443: "https", 3306: "mysql", 3389: "rdp", 5900: "vnc",
6379: "redis", 8080: "http-proxy"
}
- Port Scanning: Uses a
Queue
and threads to scan ports in the specified range. - Banner Grabbing: Attempts to identify services by grabbing banners from the HTTP server or receiving data over a socket.
- Exploitability Check: Runs
searchsploit
with the identified service name or banner information to find potential exploits.
- Python 3.6+
requests
librarysearchsploit
tool
- Execution Time: The scan can take a few minutes depending on the range of ports and the target system's response time.
- Accuracy: Not all services will respond with banners; some ports may be detected as open but provide limited or no service information.
This project is licensed under the MIT License. See the LICENSE file for more details.
Enjoy using this port scanner for network security assessments and research.