def service0x00(host): #print(R+'\n ===================================') #print(R + " S E R V I C E D E T E C T I O N") #print(R + ' ===================================\n') from core.methods.print import pscan pscan("service detection") if properties["INIT"][1] == " ": start_port = input(C+' [§] Enter initial port :> ') else: start_port = properties["INIT"][1] if properties["FIN"][1] == " ": end_port = input(C+' [§] Enter ending port :> ') else: end_port = properties["FIN"][1] start_port = int(start_port) end_port = int(end_port) open_ports = [] closed_ports = [] try: ip = socket.gethostbyname(host) print(G+'\n [+] Target server detected up and running...'+C+color.TR2+C) print(O+' [*] Preparing for scan...'+C) pass except Exception: print(R+' [-] Server not responding...') time.sleep(0.3) print(R+' [*] Exiting...') quit() if properties["VERBOSE"][1] == " ": mn = input(C+'\n [?] Do you want a verbose output (enter if not) :> ') verbose = mn != "" else: verbose = properties["VERBOSE"][1] == "1" if verbose: print(''+P+'\n [+] Verbose mode selected !\n') print(GR+" [!] Scanning %s from port %s - %s: " % (host, start_port, end_port)) print(G+" [*] Scanning started at %s" %(time.strftime("%I:%M:%S %p"))+C+color.TR2+C) starting_time = time.time() try: if verbose: print(O+" [*] Scan in progress.."+C) time.sleep(0.8) portrange = range(start_port, end_port+1) prtlst = listsplit(portrange, round(len(portrange)/processes)) with Pool(processes=processes) as pool: res = [pool.apply_async(portloop, args=(l,host,verbose,)) for l in prtlst] #res1 = pool.apply_async(portloop, ) for i in res: j = i.get() open_ports += j[0] closed_ports += j[1] print(G+"\n [+] Scanning completed at %s" %(time.strftime("%I:%M:%S %p"))+C+color.TR2+C) ending_time = time.time() total_time = ending_time - starting_time print(P+' [*] Preparing report...\n'+C) time.sleep(1) openports = " {}{}{}{}{}{}{}{} ports open.".format(color.TR5,C, G, str(len(open_ports)), color.END, color.TR2, color.END, color.CURSIVE) summary("servicedetect", openports) print() print(P+' +--------+----------+-----------+') print(P+' | '+C+'PORT '+P+'| '+C+'STATE '+P+'| '+C+'SERVICE '+P+'|') print(P+' +--------+----------+-----------+') if open_ports: data = "Port:Service >>\n" for i in sorted(open_ports): service = get_servicev(i) if not service: service = "Unknown" m = str(service) c = str(i) data = data + "\n" + c + ":" + m if len(c) == 1: print(P+' | '+C+c+P+' | '+C+'OPEN '+P+'| '+C+m+'') print(P+' +--------+----------+-----------+') time.sleep(0.2) elif len(c) == 2: print(P+' | '+C+c+' '+P+'| '+C+'OPEN '+P+'| '+C+m+'') print(P+' +--------+----------+-----------+') time.sleep(0.2) elif len(c) == 3: print(P+' | '+C+c+' '+P+'| '+C+'OPEN '+P+'| '+C+m+'') print(P+' +--------+----------+-----------+') time.sleep(0.2) elif len(c) == 4: print(P+' | '+C+c+' '+P+'| '+C+'OPEN '+P+'| '+C+m+'') print(P+' +--------+----------+-----------+') time.sleep(0.2) elif len(c) == 5: print(P+' | '+C+c+' '+P+'| '+C+'OPEN '+P+'| '+C+m+'') print(P+' +--------+----------+-----------+') time.sleep(0.2) save_data(database, module, lvl1, lvl2, lvl3, name, data) else: save_data(database, module, lvl1, lvl2, lvl3, name, "No open ports found.") print(R+"\n [-] No open ports found.!!\n") print(B+'\n [!] ' + str(len(closed_ports)) + ' closed ports not shown') print(G+" [+] Host %s scanned in %s seconds" %(host, total_time)+C+color.TR2+C+"\n") except KeyboardInterrupt: print(R+"\n [-] User requested shutdown... ") print(' [-] Exiting...\n') quit()
def scan0x00(target): try: #print(R+'\n =================================') #print(R+' T C P S T E A L T H S C A N ') #print(R+' =================================\n') from core.methods.print import pscan pscan("tcp stealth scan") if properties["INIT"][1] == " ": min_port = input(C + ' [§] Enter initial port :> ') else: min_port = properties["INIT"][1] if properties["FIN"][1] == " ": max_port = input(C + ' [§] Enter ending port :> ') else: max_port = properties["FIN"][1] open_ports = [] closed_ports = [] ip_host = socket.gethostbyname(target) if properties["VERBOSE"][1] == " ": chk = input( C + ' [?] Do you want a verbose output? (enter if not) :> ') verbose = chk != "" else: verbose = properties["VERBOSE"][1] == "1" try: print(GR + ' [*] Checking port range...') if int(min_port) >= 0 and int(max_port) >= 0 and int( max_port) >= int(min_port) and int(max_port) <= 65536: print(P + ' [!] Port range detected valid...' + C) time.sleep(0.3) print(GR + ' [*] Preparing for the scan...') pass else: print(R + "\n [!] Invalid Range of Ports") print(" [!] Exiting...") quit() except Exception: print(R + "\n [!] Invalid Range of Ports") print(" [!] Exiting...") quit() ports = range(int(min_port), int(max_port) + 1) prtlst = listsplit(ports, round(len(ports) / processes)) starting_time = time.time() SYNACK = 0x12 RSTACK = 0x14 checkhost(target) print(G + " [!] Scanning initiated at " + strftime("%H:%M:%S") + "!" + C + color.TR2 + C + "\n") # Confirm scan start with Pool(processes=processes) as pool: res = [ pool.apply_async(portloop, args=( l, verbose, ip_host, )) for l in prtlst ] #res1 = pool.apply_async(portloop, ) for i in res: j = i.get() open_ports += j[0] closed_ports += j[1] print(G + "\n [!] Scanning completed at %s" % (time.strftime("%I:%M:%S %p")) + C + color.TR2 + C) ending_time = time.time() total_time = ending_time - starting_time print(P + ' [*] Preparing report...\n' + C) time.sleep(1) openports = " {}{}{}{}{}{}{}{} ports open.".format( color.TR5, C, G, str(len(open_ports)), color.END, color.TR2, color.END, color.CURSIVE) summary("tcp stealth", openports) print() print(P + ' +--------+------------------+') print(P + ' | ' + GR + 'PORT ' + P + '| ' + C + 'STATE ' + P + '|') print(P + ' +--------+------------------+') if open_ports: for i in sorted(open_ports): c = str(i) if len(c) == 1: print(P + ' | ' + C + c + P + ' | ' + C + 'OPEN ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) elif len(c) == 2: print(P + ' | ' + C + c + ' ' + P + '| ' + C + 'OPEN ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) elif len(c) == 3: print(P + ' | ' + C + c + ' ' + P + '| ' + C + 'OPEN ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) elif len(c) == 4: print(P + ' | ' + C + c + ' ' + P + '| ' + C + 'OPEN ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) elif len(c) == 5: print(P + ' | ' + C + c + ' ' + P + '| ' + C + 'OPEN ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) print('') data = "Open Ports: " + str(open_ports) save_data(database, module, lvl1, lvl2, lvl3, name, data) else: save_data(database, module, lvl1, lvl2, lvl3, name, "No open ports found.") print('' + R + " [-] Sorry, No open ports found.!!") print(C + '\n [!] ' + str(len(closed_ports)) + ' closed ports not shown') print(G + " [+] Host %s scanned in %s seconds" % (target, total_time) + C + color.TR2 + C + "\n") except KeyboardInterrupt: print(R + "\n [-] User Requested Shutdown...") print(" [*] Exiting...") quit()
def scan0x00(host): #print(R+'\n =========================') #print(R+' P O R T S C A N N E R') #print(R+' =========================\n') from core.methods.print import pscan pscan("port scanner") print(GR + ' [*] Using most common ports...') ports = [ 20, 21, 23, 25, 53, 67, 68, 69, 80, 109, 110, 111, 123, 137, 143, 156, 161, 162, 179, 389, 443, 445, 512, 513, 546, 547, 636, 993, 995, 1099, 2121, 2049, 3306, 5432, 5900, 6000, 6667, 8080, 8180, 8443, 10000 ] mlprts = listsplit(ports, round(len(ports) / processes)) #print(mlprts) print(C + ' [+] Scanning %s ports...' % len(ports)) try: ip = socket.gethostbyname(host) print(G + '\n [+] Target server detected up and running...' + C + color.TR2 + C) print(O + ' [*] Preparing for scan...' + C) pass except Exception: print(R + ' [-] Server not responding...') time.sleep(0.3) print(R + ' [*] Exiting...') quit() open_ports = [] closed_ports = [] print(G + " [*] Scanning started at %s" % (time.strftime("%I:%M:%S %p")) + C + color.TR2 + C) starting_time = time.time() try: print(O + " [*] Scan in progress.." + C) time.sleep(0.8) with Pool(processes=processes) as pool: res = [ pool.apply_async(portloop, args=( l, host, )) for l in mlprts ] #res1 = pool.apply_async(portloop, ) for i in res: j = i.get() open_ports += j[0] closed_ports += j[1] print(G + "\n [+] Scanning completed at %s" % (time.strftime("%I:%M:%S %p")) + C + color.TR2 + C) ending_time = time.time() total_time = ending_time - starting_time print(P + ' [*] Preparing report...\n' + C) time.sleep(1) openports = " {}{}{}{}{}{}{}{} ports open.".format( color.TR5, C, G, str(len(open_ports)), color.END, color.TR2, color.END, color.CURSIVE) summary("simpleport", openports) print() print(P + ' +--------+----------+') print(P + ' | ' + C + 'PORT' + P + ' ' + '| ' + C + 'STATE' + P + ' ' + '|') print(P + ' +--------+----------+') lvl2 = "getports" module = "ScanANDEnum" lvl1 = "Scanning & Enumeration" lvl3 = "" if open_ports: for i in sorted(open_ports): c = str(i) if len(c) == 1: print(P + ' | ' + C + c + P + ' | ' + C + 'OPEN' + P + ' ' + '|') print(P + ' +--------+----------+') time.sleep(0.2) elif len(c) == 2: print(P + ' | ' + C + c + P + ' ' + P + '| ' + C + 'OPEN' + P + ' ' + '| ') print(P + ' +--------+----------+') time.sleep(0.2) elif len(c) == 3: print(P + ' | ' + C + c + P + ' ' + '| ' + C + 'OPEN' + P + ' ' + '| ') print(P + ' +--------+----------+') time.sleep(0.2) elif len(c) == 4: print(P + ' | ' + C + c + P + ' ' + '| ' + C + 'OPEN' + P + ' ' + '| ') print(P + ' +--------+----------+') time.sleep(0.2) elif len(c) == 5: print(P + ' | ' + C + c + P + ' ' + '| ' + C + 'OPEN' + P + ' ' + '| ') print(P + ' +--------+----------+') time.sleep(0.2) data = "Open Ports: " + str(open_ports) save_data(database, module, lvl1, lvl2, lvl3, name, data) else: save_data(database, module, lvl1, lvl2, lvl3, name, "No open ports found.") print(R + "\n [-] No open ports found.!!\n") print(B + '\n [!] ' + str(len(closed_ports)) + ' closed ports not shown') print(G + " [+] Host %s scanned in %s seconds" % (host, total_time) + C + color.TR2 + C + "\n") except KeyboardInterrupt: print(R + "\n [-] User requested shutdown... ") print(' [-] Exiting...\n') quit()
def scan0x00(target): try: from core.methods.print import pscan pscan("fin scan") #print(''+R+'\n =================') #print(''+R + ' F I N S C A N ') #print(''+R + ' =================') print(''+R + ' [Reliable only in LA Networks]\n') if properties["INIT"][1] == " ": min_port = input(C+' [§] Enter initial port :> ') else: min_port = properties["INIT"][1] if properties["FIN"][1] == " ": max_port = input(C+' [§] Enter ending port :> ') else: max_port = properties["FIN"][1] openfil_ports = [] filter_ports = [] closed_ports = [] ip_host = socket.gethostbyname(target) if properties["VERBOSE"][1] == " ": chk = input(C+' [?] Do you want a verbose output? (enter if not) :> ') verbose = chk != "" else: verbose = properties["VERBOSE"][1] == "1" try: print(GR+' [*] Checking port range...') if int(min_port) >= 0 and int(max_port) >= 0 and int(max_port) >= int(min_port) and int(max_port) <= 65536: print(P+' [!] Port range detected valid...'+C) time.sleep(0.3) print(GR+' [*] Preparing for the the FIN Scan...') pass else: # If range didn't raise error, but didn't meet criteria print(R+"\n [!] Invalid Range of Ports") print(R+" [!] Exiting...") quit() except Exception: # If input range raises an error print(R+"\n [!] Invalid Range of Ports") print(R+" [!] Exiting...") quit() ports = range(int(min_port), int(max_port)+1) # Build range from given port numbers starting_time = time.time() # Start clock for scan time checkhost(ip_host) # Run checkhost() function from earlier print(G+" [!] Scanning initiated at " + strftime("%H:%M:%S") + "!"+C+color.TR2+C+"\n") # Confirm scan start prtlst = listsplit(ports, round(len(ports)/processes)) with Pool(processes=processes) as pool: res = [pool.apply_async(portloop, args=(l,verbose,ip_host,)) for l in prtlst] #res1 = pool.apply_async(portloop, ) for i in res: j = i.get() openfil_ports += j[0] closed_ports += j[1] filter_ports += j[2] print(G+"\n [!] Scanning completed at %s" %(time.strftime("%I:%M:%S %p"))+C+color.TR2+C) ending_time = time.time() total_time = ending_time - starting_time print(P+' [*] Preparing report...\n'+C) time.sleep(1) openports = " {}{}{}{}{}{}{}{} ports open.".format(color.TR5,C, G, str(len(openfil_ports)), color.END, color.TR2, color.END, color.CURSIVE) summary("finscan", openports) print() print(P+' +--------+------------------+') print(P+' | '+C+'PORT '+P+'| '+C+'STATE '+P+'|') print(P+' +--------+------------------+') if openfil_ports: for i in sorted(openfil_ports): c = str(i) if len(c) == 1: print(P+' | '+C+c+P+' | '+C+'OPEN '+P+'|') print(P+' +--------+------------------+') time.sleep(0.2) elif len(c) == 2: print(P+' | '+C+c+' '+P+'| '+C+'OPEN '+P+'|') print(P+' +--------+------------------+') time.sleep(0.2) elif len(c) == 3: print(P+' | '+C+c+' '+P+'| '+C+'OPEN '+P+'|') print(P+' +--------+------------------+') time.sleep(0.2) elif len(c) == 4: print(P+' | '+C+c+' '+P+'| '+C+'OPEN '+P+'|') print(P+' +--------+------------------+') time.sleep(0.2) elif len(c) == 5: print(P+' | '+C+c+' '+P+'| '+C+'OPEN '+P+'|') print(P+' +--------+------------------+') time.sleep(0.2) data = "Open Ports: " + str(openfil_ports) save_data(database, module, lvl1, lvl2, lvl3, name, data) if filter_ports: for i in sorted(filter_ports): c = str(i) if len(c) == 1: print(P+' | '+C+c+P+' | '+C+'FILTERED '+P+'|') print(P+' +--------+------------------+') time.sleep(0.2) elif len(c) == 2: print(P+' | '+C+c+' '+P+'| '+C+'FILTERED '+P+'|') print(P+' +--------+------------------+') time.sleep(0.2) elif len(c) == 3: print(P+' | '+C+c+' '+P+'| '+C+'FILTERED '+P+'|') print(P+' +--------+------------------+') time.sleep(0.2) elif len(c) == 4: print(P+' | '+C+c+' '+P+'| '+C+'FILTERED '+P+'|') print(P+' +--------+------------------+') time.sleep(0.2) elif len(c) == 5: print(P+' | '+C+c+' '+P+'| '+C+'FILTERED '+P+'|') print(P+' +--------+------------------+') time.sleep(0.2) data = "Filtered Ports: " + str(filter_ports) save_data(database, module, lvl1, lvl2, lvl3, name, data) print('') else: print(''+R+" [-] No open/filtered ports found.!!"+'') save_data(database, module, lvl1, lvl2, lvl3, name, "No open/filtered ports found.") print(B+"\n [!] " + str(len(closed_ports)) + ' closed ports not shown') print(G+" [+] Host %s scanned in %s seconds" %(target, total_time)+C+color.TR2+C+"\n") except KeyboardInterrupt: print(R+"\n [-] User Requested Shutdown...") print(" [*] Exiting...") quit()
def check0x00(website0, gen_headers, parallel): #print(query) #print(siteinput) loggy = [] enviro = [] fud = [] generic = [] cnfy = [] gotcha = [] if properties["EVASION"][1] == " ": ev = input( C + "\n [?] Perform Evasion Attack? (specific file ; enter for no) :> " ) evasion = ev != "" else: evasion = properties["EVASION"][1] == "1" if not evasion: if properties["DICT"][1] == " ": print(C + ' [!] Enter the filename containing paths ' + O + '(Default: files/pathtrav_paths.lst)' + C) fi = input(C + " [*] Custom filepath (press Enter for default) :> ") elif properties["DICT"][1].lower() == "none": fi = "" else: fi = properties["DICT"][1] if fi == '': print(GR + ' [*] Using default filepath...') fi = getFile0x00('files/fuzz-db/pathtrav_paths.lst') else: fi = getFile0x00(fi) filepath = "" else: fi = getFile0x00('files/fuzz-db/pathtrav_evasion.lst') if properties["FILE"][1] == " ": filepath = input( " [!] Enter file and path to search (Default: etc/shadow) :> ") elif properties["FILE"][1].lower() == "none": filepath = "" else: filepath = properties["FILE"][1] if (active0 is False): owebsite = website0 else: #owebsite = ahurl owebsite = website0 print("") requests = session() if not parallel: for line in open(fi): paths = atck(evasion, filepath, owebsite, line, requests) gotcha += paths[0] generic += paths[1] loggy += paths[2] enviro += paths[3] fud += paths[4] cnfy += paths[5] else: pathlist = file2list(fi) pthlst = listsplit(pathlist, round(len(pathlist) / processes)) with Pool(processes=processes) as pool: res = [ pool.apply_async(atckpre, args=( evasion, filepath, owebsite, l, requests, )) for l in pthlst ] #res1 = pool.apply_async(portloop, ) for i in res: paths = i.get() gotcha += paths[0] generic += paths[1] loggy += paths[2] enviro += paths[3] fud += paths[4] cnfy += paths[5] #print(G+"\n [+] Retrieved %s interesting paths..." % str(len(gotcha))+C+"\n") #print("\n{}———————{}·‹› {}Pathtrav: {}{} int. paths{} ‹›·{}———————{}\n".format(color.END,C,O,G,str(len(gotcha)),C,color.END,C)) foundpaths = " {}{}{}{}{}{}{}{} paths leaked.".format( color.TR5, C, G, str(len(gotcha)), color.END, color.TR2, color.END, color.CURSIVE) summary("pathtrav", foundpaths) time.sleep(0.5) if len(loggy) > 0: printOut0x00("Logs", loggy) if len(enviro) > 0: printOut0x00("/proc/self/environ", enviro) if len(fud) > 0: printOut0x00("/proc/self/fd", fud) if len(cnfy) > 0: printOut0x00("Configuration", cnfy) if len(generic) > 0: printOut0x00("Diverse", generic)
def scan0x00(target): try: #print(R+'\n =================================') #print(R+' T C P C O N N E C T S C A N ') #print(R+' =================================\n') from core.methods.print import pscan pscan("tcp connect scan") if properties["INIT"][1] == " ": min_port = input(C + ' [§] Enter initial port :> ') else: min_port = properties["INIT"][1] if properties["FIN"][1] == " ": max_port = input(C + ' [§] Enter ending port :> ') else: max_port = properties["FIN"][1] open_ports = [] closed_ports = [] ip_host = socket.gethostbyname(target) if properties["VERBOSE"][1] == " ": chk = input( C + ' [?] Do you want a verbose output? (enter if not) :> ') verbose = chk is not "" else: verbose = properties["VERBOSE"][1] == "1" print(GR + ' [*] Checking port range...') if int(min_port) >= 0 and int(max_port) >= 0 and int(max_port) >= int( min_port) and int(max_port) <= 65536: print(P + ' [!] Port range detected valid...' + C) time.sleep(0.3) print(GR + ' [*] Preparing for the scan...') ports = range(int(min_port), int(max_port) + 1) # Build range from given port numbers prtlst = listsplit(ports, round(len(ports) / processes)) starting_time = time.time() # Start clock for scan time SYNACK = 0x12 # Set flag values for later reference RSTACK = 0x14 checkhost(ip_host) # Run checkhost() function from earlier print(G + " [!] Scanning initiated at " + strftime("%H:%M:%S") + "!" + C + color.TR2 + C + "\n") # Confirm scan start with Pool(processes=processes) as pool: res = [ pool.apply_async(portloop, args=( l, verbose, ip_host, )) for l in prtlst ] #res1 = pool.apply_async(portloop, ) for i in res: j = i.get() open_ports += j[0] closed_ports += j[1] print(G + "\n [!] Scanning completed at %s" % (time.strftime("%I:%M:%S %p")) + C + color.TR2 + C) ending_time = time.time() total_time = ending_time - starting_time print(P + ' [*] Preparing report...\n' + C) time.sleep(1) openports = " {}{}{}{}{}{}{}{} ports open.".format( color.TR5, C, G, str(len(open_ports)), color.END, color.TR2, color.END, color.CURSIVE) summary("tcp connect", openports) print() print(P + ' +--------+------------------+') print(P + ' | ' + GR + 'PORT ' + P + '| ' + C + 'STATE ' + P + '|') print(P + ' +--------+------------------+') if open_ports: for i in sorted(open_ports): c = str(i) if len(c) == 1: print(P + ' | ' + C + c + P + ' | ' + C + 'OPEN ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) elif len(c) == 2: print(P + ' | ' + C + c + ' ' + P + '| ' + C + 'OPEN ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) elif len(c) == 3: print(P + ' | ' + C + c + ' ' + P + '| ' + C + 'OPEN ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) elif len(c) == 4: print(P + ' | ' + C + c + ' ' + P + '| ' + C + 'OPEN ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) elif len(c) == 5: print(P + ' | ' + C + c + ' ' + P + '| ' + C + 'OPEN ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) print('') else: print(R + ' [-] No open ports found!') print(B + ' [!] ' + str(len(closed_ports)) + ' closed ports not shown') print(G + " [+] Host %s scanned in %s seconds" % (target, total_time) + C + color.TR2 + C + "\n") else: # If range didn't raise error, but didn't meet criteria print(R + "\n [!] Invalid Range of Ports") print(" [!] Exiting...") quit() except Exception as e: # If input range raises an error print(e) quit()
def scan0x00(target): try: #print(R+'\n ===================') #print(R+' X M A S S C A N ') #print(R+' ===================\n') from core.methods.print import pscan pscan("xmas scan") print(R + ' [Reliable only in LA Networks]\n') if properties["INIT"][1] == " ": min_port = input(C + ' [§] Enter initial port :> ') else: min_port = properties["INIT"][1] if properties["FIN"][1] == " ": max_port = input(C + ' [§] Enter ending port :> ') else: max_port = properties["FIN"][1] openfil_ports = [] filter_ports = [] closed_ports = [] ip_host = socket.gethostbyname(target) if properties["VERBOSE"][1] == " ": chk = input( C + ' [?] Do you want a verbose output? (enter if not) :> ') verbose = chk is not "" else: verbose = properties["VERBOSE"][1] == "1" try: print(GR + ' [*] Checking port range...') if int(min_port) >= 0 and int(max_port) >= 0 and int( max_port) >= int(min_port) and int(max_port) <= 65536: print(P + ' [+] Port range detected valid...' + C) time.sleep(0.3) print(GR + ' [*] Preparing for the the FIN Scan...') pass else: print(R + "\n [!] Invalid Range of Ports") print(" [!] Exiting...") quit() except Exception: # If input range raises an error print(R + "\n [!] Invalid Range of Ports") print(" [!] Exiting...") quit() ports = range(int(min_port), int(max_port) + 1) # Build range from given port numbers prtlst = listsplit(ports, round(len(ports) / processes)) starting_time = time.time() # Start clock for scan time SYNACK = 0x12 # Set flag values for later reference RSTACK = 0x14 def checkhost(ip): # Function to check if target is up conf.verb = 0 # Hide output try: ping = sr1(IP(dst=ip) / ICMP()) # Ping the target print("\n" + G + " [+] Target detected online!" + C + color.TR2 + C) time.sleep(0.6) print(O + ' [*] Beginning scan...' + C) except Exception: # If ping fails print(R + "\n [!] Couldn't Resolve Target") print(" [!] Exiting...") quit() checkhost(ip_host) # Run checkhost() function from earlier print(G + " [!] Scanning initiated at " + strftime("%H:%M:%S") + "!" + C + color.TR2 + C + "\n") # Confirm scan start with Pool(processes=processes) as pool: res = [ pool.apply_async(portloop, args=( l, verbose, ip_host, )) for l in prtlst ] #res1 = pool.apply_async(portloop, ) for i in res: j = i.get() openfil_ports += j[0] filter_ports += j[1] closed_ports += j[2] print(G + "\n [!] Scanning completed at %s" % (time.strftime("%I:%M:%S %p")) + C + color.TR2 + C) ending_time = time.time() total_time = ending_time - starting_time print(P + ' [*] Preparing report...\n' + C) time.sleep(1) openports = " {}{}{}{}{}{}{}{} ports open.".format( color.TR5, C, G, str(len(openfil_ports)), color.END, color.TR2, color.END, color.CURSIVE) summary("xmasscan", openports) print() print(P + ' +--------+------------------+') print(P + ' | ' + C + 'PORT ' + P + '| ' + C + 'STATE ' + P + '|') print(P + ' +--------+------------------+') if openfil_ports: for i in sorted(openfil_ports): c = str(i) if len(c) == 1: print(P + ' | ' + C + c + P + ' | ' + C + 'OPEN ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) elif len(c) == 2: print(P + ' | ' + C + c + ' ' + P + '| ' + C + 'OPEN ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) elif len(c) == 3: print(P + ' | ' + C + c + ' ' + P + '| ' + C + 'OPEN ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) elif len(c) == 4: print(P + ' | ' + C + c + ' ' + P + '| ' + C + 'OPEN ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) elif len(c) == 5: print(P + ' | ' + C + c + ' ' + P + '| ' + C + 'OPEN ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) if filter_ports: for i in sorted(filter_ports): c = str(i) if len(c) == 1: print(P + ' | ' + C + c + P + ' | ' + C + 'FILTERED ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) elif len(c) == 2: print(P + ' | ' + C + c + ' ' + P + '| ' + C + 'FILTERED ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) elif len(c) == 3: print(P + ' | ' + C + c + ' ' + P + '| ' + C + 'FILTERED ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) elif len(c) == 4: print(P + ' | ' + C + c + ' ' + P + '| ' + C + 'FILTERED ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) elif len(c) == 5: print(P + ' | ' + C + c + ' ' + P + '| ' + C + 'FILTERED ' + P + '|') print(P + ' +--------+------------------+') time.sleep(0.2) print('') else: print('' + R + " [-] No open/filtered ports found.!!" + R + '') print(B + "\n [!] " + str(len(closed_ports)) + ' closed ports not shown') print(G + " [+] Host %s scanned in %s seconds" % (target, total_time) + C + color.TR2 + C + "\n") except KeyboardInterrupt: # In case the user wants to quit print(R + "\n [*] User Requested Shutdown...") print(" [*] Exiting...") quit()