def runIdsLoop(self): import lib.ui.cli.core as CLIcore while 1: res = CLIcore.unified_input_prompt(self, 'nids') if res == None: break words = res.split(" ") if len(words) == 1 and words[0] == "": continue elif words[0].lower() == "run": self.runIds() elif words[0].lower() == "filter": buf = "" for word in words[1:]: buf += word + " " self.filter = buf print "Filter is:", buf elif words[0].lower() == "iface": if len(words) > 1: self.iface = words[1] if self.iface == "": self.iface = None print "Interface is:", self.iface else: print "Unknown command or option '" + str(res) + "'"
def run(self): import lib.ui.cli.core as CLIcore # Try to read last download date last_date = self.readDate() if last_date: self.gom.echo("Last exploit-db update:", last_date) # if exploits list exists, load into memory if os.path.exists(self.EXPLOITS_LIST): self.gom.echo("exploit-db already downloaded, loading on memory") self.loadExploits() while 1: res = CLIcore.unified_input_prompt(self, 'exploitdb') if res == None: break words = res.split(" ") if len(words) == 1 and words[0] == "": continue elif words[0].lower() == "fetch": self.fetchExpl() elif words[0].lower() == "list": self.listExpl() elif words[0].lower() == "search": self.search = string.join(words[1:], ' ') self.searchExpl() elif words[0].lower() == "rport": self.port = str(words[1]) self.searchPort() elif words[0].lower() == "correlate": self.correlate() elif words[0].lower() == "show": self.xplpath = str(words[1]) self.showExpl() elif words[0].lower() == 'port': self.port = words[1] self.gom.echo("New search port: ", self.port) elif words[0].lower() == 'target': self.target = words[1] self.gom.echo("Target set for correlation:", self.target) else: self.gom.echo("Unknown command or options '" + str(res) + "'") return False
def sqlLoop(self): import lib.ui.cli.core as CLIcore self.connect() buf = "" i = 1 prompt = 'oratool/sql' self.gom.echo( "Type ';' or '/' in a single line to run a command. Exit to quit.") while 1: res = CLIcore.unified_input_prompt(self, prompt) if res == None: break tmp = buf + res if res.lower().startswith("set colsize"): x = res.split(" ") self.colSize = int(x[len(x) - 1]) continue elif res in [";", "r", "/"]: if buf == "": self.gom.echo("No data in buffer") continue prompt = "oratool/sql" i = 1 self.runSQLCommand(buf, True) buf = "" elif res.endswith(";") and tmp[0:5].upper() not in [ "BEGIN", "DECLA" ]: buf += res[:len(res) - 1] + "\n" prompt = "oratool/sql" self.runSQLCommand(buf, True) buf = "" else: buf += res + "\n" i += 1 prompt = " %d " % i
def p0fLoop(self): import lib.ui.cli.core as CLIcore while 1: res = CLIcore.unified_input_prompt(self, 'p0f') if res == None: break words = res.split(" ") if len(words) == 1 and words[0] == "": continue elif words[0].lower() == "filter": buf = "" for word in words[1:]: buf += word + " " self.filter = buf self.gom.echo("Filter is:", buf) elif words[0].lower() in ["p0f", "run"]: try: self.gom.echo("Sniffing in iface", self.iface, "...") if bScapy: self.data = scapy.sniff(prn=self.prnp0f, filter=self.filter, iface=self.iface) else: self.gom.echo("No scapy support :(") except KeyboardInterrupt: break except: self.gom.echo("Internal error.", sys.exc_info()[1]) elif words[0].lower() == "iface": if len(words) > 1: self.iface = words[1] self.gom.echo("Interface is:", self.iface) else: self.gom.echo("Unknown command or options '" + str(res) + "'") return True
def run(self): import lib.ui.cli.core as CLIcore while 1: res = CLIcore.unified_input_prompt(self, 'nmapscan') if res == None: break words = res.split(" ") if len(words) == 1 and words[0] == "": continue elif words[0].lower() == "nmap" and len(words) > 1: mystring = string.join(words, ' ') self.run_nmap(mystring) elif words[0].lower() == "nmaphelp": self.help_nmap() else: self.gom.echo("Unknown option or command '%s'" % res) return True
def runOracleModeLoop(self): import lib.ui.cli.core as CLIcore dad = self.dad sid = self.sid port = self.port target = self.target user = self.user password = self.password while 1: res = CLIcore.unified_input_prompt(self, 'oratool') if res == None: break self.dad = dad self.sid = sid self.target = target self.port = port self.user = user self.password = password words = res.split(" ") if len(words) == 1 and words[0] == "": continue elif words[0].lower() == "sql": self.sqlLoop() elif words[0].lower() == "show" and words[1].lower() == "exploits": self.showExploits() else: try: exec(res) except: print "Error:", sys.exc_info()[1] return True
def main_loop(): """ Main execution loop after initialization. """ import lib.ui.cli.core as CLIcore global prompt global oldPrompt global prevRes global target global port global covert global timeout global waittime global debug oldPrompt = "" prevRes = "" inguma = Inguma(hasScapy) while 1: res = CLIcore.unified_input_prompt(inguma) if res == None: print "Exit." sys.exit(0) if res == "" and prevRes == "": pass elif res.lower() == "save kb": saveKb() elif res.lower() == "clear kb": clearKb() elif res.lower() == "load kb": loadKb() elif res.lower() == "show kb": showKb() elif res.lower() == "show discover": showDiscover() elif res.lower() == "show gather": showGather() elif res.lower() == "show rce": showRce() elif res.lower() == "show fuzzers": showFuzzers() elif res.lower() == "show brute": showBrutes() elif res.lower() == "autoscan": doAutoScan() elif res.lower() == "report": generateReport(user_data) elif res.lower() == "payload": printPayloads() elif res != "" and prevRes != "": prevRes += "\n" + res elif res == "" and prevRes != "": try: if prevRes != "": prevRes += "\n" + res res = prevRes exec(GLOBAL_VARIABLES + res) except: print "Exec error:", sys.exc_info()[1] prevRes = "" if oldPrompt != "": prompt = oldPrompt oldPrompt = "" elif res[len(res) - 1] == ":": oldPrompt = prompt prompt = ">>>>>>> " prevRes = res else: try: if not runCommand(res, locals()): exec(GLOBAL_VARIABLES + res) except: print "Internal error.", sys.exc_info()[1] if debug: raise
def main_loop(): """ Main execution loop after initialization. """ global prompt global oldPrompt global prevRes global target global port global covert global timeout global waittime oldPrompt = "" prevRes = "" inguma = Inguma(hasScapy) while 1: res = uicore.unified_input_prompt(inguma) if res == None: glob.gom.echo("Exit.") return False if res == "" and prevRes == "": pass elif res.lower() == "save kb": # FIXME: We cannot use globals inside the KnowledgeBase class, so # we have to assign the 'target' global variable to a glob attribute # prior to calling the class method. glob.target = target res = input('Filename [%s]: ' % glob.kb.default_filename) if res: glob.kb.save(res) else: glob.kb.save() # FIXME: We cannot use globals inside the KnowledgeBase class, so # we have to reassign the 'target' global variable after calling # it. 'global target' is defined above in the function, target = glob.target elif res.lower() == "clear kb": glob.kb.reset() elif res.lower() == "load kb": # FIXME: We cannot use globals inside the KnowledgeBase class, so # we have to assign the 'target' global variable to a glob attribute # prior to calling the class method. glob.target = target glob.gom.echo('* Warning! Warning! Warning! Warning! Warning! Warning! *') glob.gom.echo('*** Never load KB files received from untrusted sources ***') res = input('Filename [%s]: ' % glob.kb.default_filename) if res: glob.kb.load(res) else: glob.kb.load() # FIXME: We cannot use globals inside the KnowledgeBase class, so # we have to reassign the 'target' global variable after calling # it. 'global target' is defined above in the function, target = glob.target elif res.lower() == "show kb": glob.gom.echo(glob.kb.format_text()) elif res.lower() == "show discover": showDiscover() elif res.lower() == "show gather": showGather() elif res.lower() == "show rce": showRce() elif res.lower() == "show fuzzers": showFuzzers() elif res.lower() == "show brute": showBrutes() elif res.lower() == "autoscan": doAutoScan() elif res.lower() == "report": generateReport(user_data) elif res.lower() == "payload": printPayloads() elif res != "" and prevRes != "": prevRes += "\n" + res elif res == "" and prevRes != "": try: if prevRes != "": prevRes += "\n" + res res = prevRes exec(glob.GLOBAL_VARIABLES + res) except: print("Exec error:",sys.exc_info()[1]) prevRes = "" if oldPrompt != "": prompt = oldPrompt oldPrompt = "" elif res[len(res)-1] == ":": oldPrompt = prompt prompt = ">>>>>>> " prevRes = res else: try: if not runCommand(res, locals()): exec(glob.GLOBAL_VARIABLES + res) except: print("Internal error.",sys.exc_info()[1]) if glob.debug: raise