def linker(target, path, proto, folder, out): fullpath = str(folder) + "/" + str(out) fulllinks = str(folder) + "/links.txt" url = 0 parsing = 0 i = 0 progress = 0 percent = 0 nb_lines = total_lines(folder, out) if os.path.exists(fullpath): print(status.ok(), "File found: " + fullpath) f = open(fullpath, 'r') if os.path.exists(fulllinks): os.remove(fulllinks) r = open(fulllinks, 'w+') print(status.st(), "Searching Urls") line = f.readline() while line: progress += 1 sys.stdout.write("Found: " + colors.green() + str(url) + colors.reset() + " Progress: " + colors.cyan() + "%d" % percent + colors.reset() + "%") sys.stdout.flush() sys.stdout.write('\b' * (7 + 11 + len(str(url)) + len(str(percent)))) sys.stdout.flush() while i < len(line) - 1: if line[i] == '/' and line[i - 1] == "\"" and line[i + 1] != '>': while line[i] != "\"" and i < len(line) - 1: r.write(line[i]) i += 1 r.write('\n') url += 1 if line[i] == '/' and line[i - 1] == "'" and line[i + 1] != '>': while line[i] != "'" and i < len(line) - 1: r.write(line[i]) i += 1 r.write('\n') i += 1 i = 0 line = f.readline() percent = ((nb_lines / progress) * 100) f.close() r.close() print("Found: " + colors.green() + str(url) + colors.reset() + " Progress: " + colors.cyan() + "%d" % percent + colors.reset() + "% => '" + colors.purple() + fulllinks + colors.reset() + "'") else: print(status.ok(), "File not found: " + fullpath)
def basic(target): try: print(status.st(), "Executing: 'nmap %s'" % target) os.system('nmap %s' % target) except: print(status.ko(), "Error occured during the NMAP's scan") else: print(status.ok(), "Execution: 'nmap %s' completed" % target)
def execute(target, script): try: print(status.st(), "Executing: 'nmap --script %s %s'" % (script, target)) os.system('nmap --script %s %s' % (script, target)) except: print(status.ko(), "Error occured during the NMAP's scan") else: print(status.ok(), "Execution: 'nmap --script %s %s' completed" % (script, target))
def ping(target): packet = "10" cont = None print(status.st(), "Checking your internet connection with '8.8.8.8'") handshake = os.system("ping -c %s 8.8.8.8 -q" % packet) if handshake != 0: print(status.ko(), "Connection on your internet failed") cont = input(status.iu() + " Continue [Y|n]: ") if cont != 'Y': exit(84) else: print(status.ok() + " Connection successfully etablished on your internet connection") print(status.st(), "Connecting to the target '%s'" % target) handshake = os.system("ping -c %s %s -q" % (packet, target)) if handshake != 0: print(status.ko(), "Connection on target '%s' failed" % target) cont = input(status.iu() + " Continue [Y|n]: ") if cont != 'Y': exit(84) else: print(status.ok(), "Connection successfully etablished on target '%s'" % target)
def folder(folder): remove = None print(status.st(), "Creating the folder's scan: '%s'" % folder) if os.path.exists(folder): print(status.iu(), "The folder named '%s' already exists" % folder) remove = input(status.iu() + " Do you want to remove the folder '%s' [Y|n]: " % folder) if remove == 'Y': print(status.st(), "Removing the folder '%s'" % folder) try: shutil.rmtree(folder) except OSError: print(status.ko(), "Deletion of the directory '%s' failed" % folder) else: print(status.ok(), "Successfully deleted the directory '%s'" % folder) else: print(status.ko(), "Aboarting the creation, exiting program") exit(0) try: os.mkdir(folder) except OSError: print(status.ko(), "Creation of the directory '%s' failed" % folder) else: print(status.ok(), "Successfully created the directory '%s'" % folder)
def scan(): while settings.USER != 'exit': settings.USER = input("%s Username: "******"\n%s Exiting" % status.working()) exit(0) else: if check(settings.USER) == 0: try: resp = connection() if resp.status_code == 200: print("\n%s Connection success" % (status.ok())) parse(resp) else: print("\n%s Connection failed" % (status.error())) except: print("\n%s Connection failed" % (status.error()))
def custom(target): script = None extracted = None choice = input(status.iu() + " Do you want to start custom nmap's scripts [Y|n]: ") if choice == 'Y': print(status.io(), "When you finished type 'exit' to stop 'NMAP' session") print( status.io(), "Default path of the nmap's scripts: '" + colors.purple() + "/usr/share/nmap/scripts" + colors.reset() + "'") while script != "exit": script = input(status.iu() + " FULL path of the nmap script: ") if script != "exit": print(status.st(), "Checking the script's file") if os.path.exists(script): print(status.ok(), "Script's file found") extracted = extract_script(script) execute(target, extracted) else: print(status.ko(), "Script's file no found")
def nmap(target): print(status.st(), "Starting session 'NMAP'") basic(target) custom(target) print(status.ok(), "Session 'NMAP' ended")