-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscanner.py
More file actions
35 lines (31 loc) · 1.42 KB
/
scanner.py
File metadata and controls
35 lines (31 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import nmap
from datetime import datetime
from colorama import Fore, Style
class VulnerabilityScanner:
def __init__(self):
self.nm = nmap.PortScanner()
self.results = {}
def scan(self, target, arguments='-sV -sC --top-ports 1000'):
print(f"{Fore.CYAN}Scanning {target}...{Style.RESET_ALL}")
self.nm.scan(hosts=target, arguments=arguments)
for host in self.nm.all_hosts():
self.results[host] = {
'status': self.nm[host].state(),
'ports': {}
}
for proto in self.nm[host].all_protocols():
for port in self.nm[host][proto]:
port_info = self.nm[host][proto][port]
self.results[host]['ports'][port] = {
'state': port_info['state'],
'service': port_info.get('name', 'unknown'),
'version': port_info.get('product', '') + ' ' + port_info.get('version', '')
}
return self.results
def print_summary(self):
print(f"\n{Fore.GREEN}=== Scan Summary ==={Style.RESET_ALL}")
for host, data in self.results.items():
print(f"\nHost: {host} - Status: {data['status']}")
for port, info in data['ports'].items():
if info['state'] == 'open':
print(f" [+] Port {port:<5} open → {info['service']} {info['version']}")