class NmapScan(): def __init__(self, host, disablePing=False): # print("[+] Starting nmap scan...") self.host = host self.disablePing = disablePing self.nmap = Nmap() def fullScan(self): print(colored("[+] Starting nmap full scan...", 'green')) disablePing = '-Pn' if self.disablePing else '' return self.nmap.scan_top_ports( target=self.host, args="-T4 -A -sV --version-intensity 9 --script vuln -p- {}". format(disablePing)) def quickScan(self): print(colored("[+] Starting nmap quick scan...", 'green')) disablePing = '-Pn' if self.disablePing else '' return self.nmap.scan_top_ports(target=self.host, args='{}'.format(disablePing)) def enumPort(self, port, scripts): print(colored("\t[+] Starting nmap scripts...", 'green')) disablePing = '-Pn' if self.disablePing else '' return self.nmap.scan_top_ports(target=self.host, args='-p {} --script={} {}'.format( port, ','.join(scripts).replace(' ', ''), disablePing)) def scan(self): return self.quickScan()
def scan_top_ports(domains): nmap = Nmap() print(Fore.WHITE + "\n====================================================") print(Fore.WHITE + " Scna top ports |") print(Fore.WHITE + "====================================================\n") print(Fore.WHITE + 'It is working, wait ....\n') print('-' * 47) try: for domain in domains: results = nmap.scan_top_ports(domain) for res in results[list(results)[0]]['ports']: print(Fore.WHITE + "[*] [ {} ] {}-{} --- > {} ".format( domain, res['portid'], res['protocol'], res['state'])) print('-' * 47) except: print('eroor')