def dns(target): from socket import gethostbyname from nmap3 import Nmap , NmapScanTechniques nmap = Nmap() ip_addr = gethostbyname(target) subdomains = nmap.nmap_dns_brute_script(target) return(ip_addr, subdomains)
def __init__(self, ip): self.ip = ip self.is_iot = None self.__nmap = Nmap() self.__device_vendor = set() self.__device_type = set() self.__device_os_family = set() self.__device_os_name = set() self.__device_mac = None self.__device_mac_vendor = None self.__ports_to_scan = ports_to_scan
def analyze(self): self.exposed_services = [] nmap = Nmap() results = nmap.nmap_version_detection(self.ip, args="-Pn") for r in results: if 'service' in r: service_info = r['service'] if 'product' in service_info: service = service_info['product'] if 'version' in service_info: service += " " + service_info['version'] self.exposed_services.append(service)
def run(self): from nmap3 import Nmap from nmap3.exceptions import NmapNotInstalledError try: result = Nmap().nmap_os_detection(self.__dict__["host"]) print(dumps(result, indent=2)) if self.__dict__["to_file"].strip().lower() == "true": with open(f"{self.__dict__['host']}_os_detection.json", "w") as fd: fd.write(dumps(result, indent=4)) print("[**]::nmap results written to file") except NmapNotInstalledError: print("[!!]::Nmap must be intstalled in order to use Nmap modules") return
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')
def web_service(target): from nmap3 import Nmap nmap = Nmap() version_result = nmap.nmap_version_detection(target) return(version_result)
def __init__(self, host, disablePing=False): # print("[+] Starting nmap scan...") self.host = host self.disablePing = disablePing self.nmap = Nmap()