diff --git a/modules/gameserver.py b/modules/gameserver.py index dec9e3f..fe9f54a 100644 --- a/modules/gameserver.py +++ b/modules/gameserver.py @@ -7,6 +7,7 @@ BLUE, RED, WHITE, YELLOW, MAGENTA, GREEN, END = '\33[1;94m', '\033[1;91m', '\33[1;97m', '\33[1;93m', '\033[1;35m', '\033[1;32m', '\033[0m' + class ThreadManager(object): i = 0 @@ -24,6 +25,7 @@ def getNextIp(self): def getID(self): return self.i + 1 + def coreOptions(): options = [["network", "IP range to scan", ""], ["port-timeout", "Timeout (in sec) for port 80.", "0.3"], ["threads", "Number of threads to run.", "100"], ["verbose", "Show verbose output.", "true"]] @@ -37,10 +39,12 @@ def createIPList(network): ipList.append(x) return ipList + def print1(data): if verbose: print("\033[K" + data) + def checkServer(address, port): s = socket.socket() s.settimeout(float(portTimeout)) @@ -55,6 +59,7 @@ def checkServer(address, port): s.close() return "FAIL" + def writeToFile(line): file = open(fileName, "a") file.write(line) @@ -102,7 +107,7 @@ def scan(i): possibleGame = tempPort[1] openPorts = openPorts + 1 - print1(GREEN + "[+] Port " + str(port) + " is open on '" + stringIP + "' - " + possibleGame + END) + print1(GREEN + "[+] Port " + str(port) + " is open on '" + stringIP + "' - " + possibleGame + END) logLine = stringIP + " - " + str(port) + " OPEN - " + possibleGame + "\n" logLines.append(logLine) elif not isUp: @@ -114,7 +119,8 @@ def scan(i): def core(moduleOptions): print( - "\n" + GREEN + "GameServer module by @xdavidhu. Scanning subnet '" + YELLOW + moduleOptions[0][2] + GREEN + "'...\n") + "\n" + GREEN + "GameServer module by @xdavidhu. Scanning subnet '" + YELLOW + moduleOptions[0][ + 2] + GREEN + "'...\n") global status global fileName @@ -185,9 +191,9 @@ def core(moduleOptions): break statusWidget() except KeyboardInterrupt: - stop = True - verbose = False - print("\n" + RED + "[I] Stopping..." + END) + stop = True + verbose = False + print("\n" + RED + "[I] Stopping..." + END) stop = True verbose = False diff --git a/modules/http.py b/modules/http.py index 87bf219..7c399d3 100644 --- a/modules/http.py +++ b/modules/http.py @@ -9,6 +9,7 @@ BLUE, RED, WHITE, YELLOW, MAGENTA, GREEN, END = '\33[1;94m', '\033[1;91m', '\33[1;97m', '\33[1;93m', '\033[1;35m', '\033[1;32m', '\033[0m' + class ThreadManager(object): i = 0 @@ -26,9 +27,11 @@ def getNextIp(self): def getID(self): return self.i + 1 + def coreOptions(): options = [["network", "IP range to scan", ""], ["port-timeout", "Timeout (in sec) for port 80.", "0.3"], - ["title-timeout", "Timeout (in sec) for title resolve.", "3"], ["threads", "Number of threads to run.", "50"], + ["title-timeout", "Timeout (in sec) for title resolve.", "3"], + ["threads", "Number of threads to run.", "50"], ["verbose", "Show verbose output.", "true"]] return options @@ -40,10 +43,12 @@ def createIPList(network): ipList.append(x) return ipList + def print1(data): if verbose: print("\033[K" + data) + def checkServer(address, port): s = socket.socket() s.settimeout(float(portTimeout)) @@ -225,9 +230,9 @@ def core(moduleOptions): break statusWidget() except KeyboardInterrupt: - stop = True - verbose = False - print("\n" + RED + "[I] Stopping..." + END) + stop = True + verbose = False + print("\n" + RED + "[I] Stopping..." + END) stop = True verbose = False diff --git a/modules/manual.py b/modules/manual.py index 039cf52..b9cc151 100644 --- a/modules/manual.py +++ b/modules/manual.py @@ -7,6 +7,7 @@ BLUE, RED, WHITE, YELLOW, MAGENTA, GREEN, END = '\33[1;94m', '\033[1;91m', '\33[1;97m', '\33[1;93m', '\033[1;35m', '\033[1;32m', '\033[0m' + class ThreadManager(object): i = 0 @@ -24,8 +25,10 @@ def getNextIp(self): def getID(self): return self.i + 1 + def coreOptions(): - options = [["network", "IP range to scan", ""], ["ports", "Comma separated list of ports to scan. (e.g: '21,22,53')", ""], + options = [["network", "IP range to scan", ""], + ["ports", "Comma separated list of ports to scan. (e.g: '21,22,53')", ""], ["port-timeout", "Timeout (in sec) for port 80.", "0.3"], ["threads", "Number of threads to run.", "50"], ["verbose", "Show verbose output.", "true"]] return options @@ -38,10 +41,12 @@ def createIPList(network): ipList.append(x) return ipList + def print1(data): if verbose: print("\033[K" + data) + def checkServer(address, port): s = socket.socket() s.settimeout(float(portTimeout)) @@ -56,6 +61,7 @@ def checkServer(address, port): s.close() return "FAIL" + def writeToFile(line): file = open(fileName, "a") file.write(line) @@ -112,7 +118,8 @@ def scan(i): def core(moduleOptions): print( - "\n" + GREEN + "MANUAL module by @xdavidhu. Scanning subnet '" + YELLOW + moduleOptions[0][2] + GREEN + "'...\n") + "\n" + GREEN + "MANUAL module by @xdavidhu. Scanning subnet '" + YELLOW + moduleOptions[0][ + 2] + GREEN + "'...\n") global status global fileName @@ -200,9 +207,9 @@ def core(moduleOptions): break statusWidget() except KeyboardInterrupt: - stop = True - verbose = False - print("\n" + RED + "[I] Stopping..." + END) + stop = True + verbose = False + print("\n" + RED + "[I] Stopping..." + END) stop = True verbose = False diff --git a/modules/mongodb.py b/modules/mongodb.py index b63cb36..fe6dce0 100644 --- a/modules/mongodb.py +++ b/modules/mongodb.py @@ -8,6 +8,7 @@ BLUE, RED, WHITE, YELLOW, MAGENTA, GREEN, END = '\33[1;94m', '\033[1;91m', '\33[1;97m', '\33[1;93m', '\033[1;35m', '\033[1;32m', '\033[0m' + class ThreadManager(object): i = 0 @@ -25,6 +26,7 @@ def getNextIp(self): def getID(self): return self.i + 1 + def checkMongo(host, port): try: con = pymongo.MongoClient(host=host, port=port, connectTimeoutMS=mongoTimeout) @@ -49,11 +51,14 @@ def checkMongo(host, port): return ["success", serverVersion, dbs] + def coreOptions(): options = [["network", "IP range to scan", ""], ["port", "Port to scan.", "27017"], - ["port-timeout", "Timeout (in sec) for port 80.", "0.3"], ["mongo-timeout", "Timeout (in sec) for the database connection.", "3"], + ["port-timeout", "Timeout (in sec) for port 80.", "0.3"], + ["mongo-timeout", "Timeout (in sec) for the database connection.", "3"], ["threads", "Number of threads to run.", "50"], - ["checkauth", "Connect to the server and perform tests.", "true"], ["verbose", "Show verbose output.", "true"]] + ["checkauth", "Connect to the server and perform tests.", "true"], + ["verbose", "Show verbose output.", "true"]] return options @@ -64,10 +69,12 @@ def createIPList(network): ipList.append(x) return ipList + def print1(data): if verbose: print("\033[K" + data) + def checkServer(address, port): s = socket.socket() s.settimeout(float(portTimeout)) @@ -128,11 +135,13 @@ def scan(i): if mongo[0] == "conection-error": mongoStatus = False mongoStatusReason = "CONNECTION ERROR" - print1(RED + "[!] Failed connecting to the database on '" + stringIP + "'. ERROR: " + mongoStatusReason + END) + print1( + RED + "[!] Failed connecting to the database on '" + stringIP + "'. ERROR: " + mongoStatusReason + END) elif mongo[0] == "permission-error": mongoStatus = False mongoStatusReason = "PERMISSION ERROR" - print1(RED + "[!] Failed connecting to the database on '" + stringIP + "'. ERROR: " + mongoStatusReason + END) + print1( + RED + "[!] Failed connecting to the database on '" + stringIP + "'. ERROR: " + mongoStatusReason + END) elif mongo[0] == "success": mongoStatus = True version = mongo[1] @@ -146,16 +155,21 @@ def scan(i): else: dbsList = "-" - print1(GREEN + "[+] Open database found:\n\tIP: " + stringIP + "\n\t" + "MongoDB version: " + str(version) + "\n\tDB's: " + dbsList + "\n") + print1( + GREEN + "[+] Open database found:\n\tIP: " + stringIP + "\n\t" + "MongoDB version: " + str( + version) + "\n\tDB's: " + dbsList + "\n") else: - print1(RED + "[!] Failed connecting to the database on '" + stringIP + "'. ERROR: " + mongoStatusReason + END) + print1( + RED + "[!] Failed connecting to the database on '" + stringIP + "'. ERROR: " + mongoStatusReason + END) mongoStatus = False if mongoStatus: - logLine = stringIP + " - " + str(port) + " OPEN" + " - " + "OPEN DATABASE - Version: " + version + " - " + " DB's: " + dbsList + "\n" + logLine = stringIP + " - " + str( + port) + " OPEN" + " - " + "OPEN DATABASE - Version: " + version + " - " + " DB's: " + dbsList + "\n" else: - logLine = stringIP + " - " + str(port) + " OPEN" + " - DB SCAN ERROR: " + mongoStatusReason + "\n" + logLine = stringIP + " - " + str( + port) + " OPEN" + " - DB SCAN ERROR: " + mongoStatusReason + "\n" logLines.append(logLine) else: logLine = stringIP + " - " + str(port) + " OPEN\n" @@ -169,7 +183,8 @@ def scan(i): def core(moduleOptions): print( - "\n" + GREEN + "MONGODB module by @xdavidhu. Scanning subnet '" + YELLOW + moduleOptions[0][2] + GREEN + "'...\n") + "\n" + GREEN + "MONGODB module by @xdavidhu. Scanning subnet '" + YELLOW + moduleOptions[0][ + 2] + GREEN + "'...\n") global status global fileName @@ -260,9 +275,9 @@ def core(moduleOptions): break statusWidget() except KeyboardInterrupt: - stop = True - verbose = False - print("\n" + RED + "[I] Stopping..." + END) + stop = True + verbose = False + print("\n" + RED + "[I] Stopping..." + END) stop = True verbose = False diff --git a/modules/mysql.py b/modules/mysql.py index 28be7c4..a3e289d 100644 --- a/modules/mysql.py +++ b/modules/mysql.py @@ -8,6 +8,7 @@ BLUE, RED, WHITE, YELLOW, MAGENTA, GREEN, END = '\33[1;94m', '\033[1;91m', '\33[1;97m', '\33[1;93m', '\033[1;35m', '\033[1;32m', '\033[0m' + class ThreadManager(object): i = 0 @@ -25,6 +26,7 @@ def getNextIp(self): def getID(self): return self.i + 1 + def checkSQL(host, port): loginFail = False try: diff --git a/modules/printer.py b/modules/printer.py index 968cfb8..dafe21b 100644 --- a/modules/printer.py +++ b/modules/printer.py @@ -9,6 +9,7 @@ BLUE, RED, WHITE, YELLOW, MAGENTA, GREEN, END = '\33[1;94m', '\033[1;91m', '\33[1;97m', '\33[1;93m', '\033[1;35m', '\033[1;32m', '\033[0m' + class ThreadManager(object): i = 0 @@ -26,9 +27,11 @@ def getNextIp(self): def getID(self): return self.i + 1 + def coreOptions(): options = [["network", "IP range to scan", ""], ["port-timeout", "Timeout (in sec) for port 80.", "0.3"], - ["title-timeout", "Timeout (in sec) for title resolve.", "3"], ["threads", "Number of threads to run.", "50"], + ["title-timeout", "Timeout (in sec) for title resolve.", "3"], + ["threads", "Number of threads to run.", "50"], ["verbose", "Show verbose output.", "true"]] return options @@ -40,10 +43,12 @@ def createIPList(network): ipList.append(x) return ipList + def print1(data): if verbose: print("\033[K" + data) + def checkServer(address, port): s = socket.socket() s.settimeout(float(portTimeout)) @@ -174,7 +179,8 @@ def scan(i): def core(moduleOptions): print( - "\n" + GREEN + "PRINTER module by @xdavidhu. Scanning subnet '" + YELLOW + moduleOptions[0][2] + GREEN + "'...\n") + "\n" + GREEN + "PRINTER module by @xdavidhu. Scanning subnet '" + YELLOW + moduleOptions[0][ + 2] + GREEN + "'...\n") global status global fileName @@ -245,9 +251,9 @@ def core(moduleOptions): break statusWidget() except KeyboardInterrupt: - stop = True - verbose = False - print("\n" + RED + "[I] Stopping..." + END) + stop = True + verbose = False + print("\n" + RED + "[I] Stopping..." + END) stop = True verbose = False diff --git a/modules/ssh.py b/modules/ssh.py index 4274dc7..7179b66 100644 --- a/modules/ssh.py +++ b/modules/ssh.py @@ -7,6 +7,7 @@ BLUE, RED, WHITE, YELLOW, MAGENTA, GREEN, END = '\33[1;94m', '\033[1;91m', '\33[1;97m', '\33[1;93m', '\033[1;35m', '\033[1;32m', '\033[0m' + class ThreadManager(object): i = 0 @@ -24,6 +25,7 @@ def getNextIp(self): def getID(self): return self.i + 1 + def coreOptions(): options = [["network", "IP range to scan", ""], ["port-timeout", "Timeout (in sec) for port 80.", "0.3"], ["threads", "Number of threads to run.", "50"], ["verbose", "Show verbose output.", "true"]] @@ -37,10 +39,12 @@ def createIPList(network): ipList.append(x) return ipList + def print1(data): if verbose: print("\033[K" + data) + def checkServer(address, port): s = socket.socket() s.settimeout(float(portTimeout)) @@ -56,6 +60,7 @@ def checkServer(address, port): s.close() return "FAIL" + def writeToFile(line): file = open(fileName, "a") file.write(line) @@ -95,7 +100,8 @@ def scan(i): if isUp[0] != "FAIL": if isUp[0] == "True": openPorts = openPorts + 1 - print1(GREEN + "[+] Port " + str(port) + " is open on '" + stringIP + "' - Connection response: " + str(isUp[1]) + END) + print1(GREEN + "[+] Port " + str(port) + " is open on '" + stringIP + "' - Connection response: " + str( + isUp[1]) + END) logLine = stringIP + " - " + str(isUp[1]) + "\n" logLines.append(logLine) elif not isUp[0] == "True": @@ -177,9 +183,9 @@ def core(moduleOptions): break statusWidget() except KeyboardInterrupt: - stop = True - verbose = False - print("\n" + RED + "[I] Stopping..." + END) + stop = True + verbose = False + print("\n" + RED + "[I] Stopping..." + END) stop = True verbose = False diff --git a/modules/template.py b/modules/template.py index 81d816b..c00f280 100644 --- a/modules/template.py +++ b/modules/template.py @@ -1,9 +1,10 @@ def coreOptions(): - options = [["testvar1", "testvar1 description", ""], ["testvar2", "testvar2 description", "testvar2 pre-set value"], ["var3", "var3 description", ""]] + options = [["testvar1", "testvar1 description", ""], ["testvar2", "testvar2 description", "testvar2 pre-set value"], + ["var3", "var3 description", ""]] return options -def core(moduleOptions): +def core(moduleOptions): testvar1value = moduleOptions[0][2] testvar2value = moduleOptions[1][2] var3value = moduleOptions[2][2] @@ -12,4 +13,4 @@ def core(moduleOptions): print("testvar1: " + str(testvar1value)) print("testvar2: " + str(testvar2value)) - print("var3: " + str(var3value)) \ No newline at end of file + print("var3: " + str(var3value)) diff --git a/portSpider.py b/portSpider.py index a202548..5239336 100755 --- a/portSpider.py +++ b/portSpider.py @@ -3,7 +3,6 @@ BLUE, RED, WHITE, YELLOW, MAGENTA, GREEN, END = '\33[1;94m', '\033[1;91m', '\33[1;97m', '\33[1;93m', '\033[1;35m', '\033[1;32m', '\033[0m' - try: import os import traceback @@ -25,12 +24,14 @@ ["gameserver", "Scan for open game server ports."], ["manual", "Scan custom ports."], ["template", "Template module for developers."]] -textToModule = [["http", http], ["template", template], ["printer", printer], ["gameserver", gameserver], ["ssh", ssh], ["manual", manual], ["mongodb", mongodb], ["mysql", mysql]] +textToModule = [["http", http], ["template", template], ["printer", printer], ["gameserver", gameserver], ["ssh", ssh], + ["manual", manual], ["mongodb", mongodb], ["mysql", mysql]] inModule = False currentModule = "" moduleOptions = [] + def commandHandler(command): command = str(command) command = command.lower() @@ -45,6 +46,7 @@ def commandHandler(command): # HELP def helpPrint(name, desc, usage): print("\t" + YELLOW + name + GREEN + ": " + BLUE + desc + GREEN + " - '" + usage + "'" + END) + if command == "help": print(GREEN + "\n[I] Available commands:\n" + END) helpPrint("MODULES", "List all modules", "modules") @@ -75,7 +77,8 @@ def helpPrint(name, desc, usage): else: print(RED + "[!] Module '" + YELLOW + tempModule + RED + "' not found." + END) else: - print(RED + "[!] Module '" + YELLOW + currentModule + RED + "' already selected. Type '" + YELLOW + "back" + RED + "' to go back to the main menu." + END) + print( + RED + "[!] Module '" + YELLOW + currentModule + RED + "' already selected. Type '" + YELLOW + "back" + RED + "' to go back to the main menu." + END) elif command == "use": print(RED + "[!] Usage: 'use " + YELLOW + "module_name" + RED + "'" + END) @@ -85,7 +88,8 @@ def helpPrint(name, desc, usage): print(GREEN + "\n Options for module '" + YELLOW + currentModule + GREEN + "':" + END) for option in moduleOptions: if option[2] == "": - print("\t" + YELLOW + option[0] + GREEN + " - " + BLUE + option[1] + GREEN + " ==> " + RED + "[NOT SET]" + END) + print("\t" + YELLOW + option[0] + GREEN + " - " + BLUE + option[ + 1] + GREEN + " ==> " + RED + "[NOT SET]" + END) else: print("\t" + YELLOW + option[0] + GREEN + " - " + BLUE + option[1] + GREEN + " ==> '" + YELLOW + option[2] + GREEN + "'" + END) @@ -175,7 +179,9 @@ def helpPrint(name, desc, usage): pass else: - print(RED + "[!] Unknown command: '" + YELLOW + command + RED + "'. Type '" + YELLOW + "help" + RED + "' for all available commands." + END) + print( + RED + "[!] Unknown command: '" + YELLOW + command + RED + "'. Type '" + YELLOW + "help" + RED + "' for all available commands." + END) + parser = argparse.ArgumentParser(description="portSpider") parser.add_argument("--test", action='store_true') @@ -203,7 +209,7 @@ def helpPrint(name, desc, usage): i = 0 for module in allModules: i += 1 - if i%7 == 0: + if i % 7 == 0: moduleList += "\n" moduleList = moduleList + YELLOW + module[0] + GREEN + ", " moduleList = moduleList[:-2]