def show(self, option): var = "modules" if "windows" in option: var = var + sep + "windows" elif "linux" in option: var = var + sep + "linux" elif "mac" in option: var = var + sep + "mac" elif "multi" in option: var = var + sep + "multi" elif "all" in option: pass elif "listeners" in option: var = var + sep + "listener" elif ("options" in option or "info" in option) and self.myModule: self.myModule.show(option) return else: custom_print.error("show >> try with other option. " + option + " not found...") return for root, dirs, files in walk(var): for file in files: if ".py" == file[-3:] and file != "model.py" and file[0] != "_": path = root.split(sep)[1:] print(sep.join(path) + sep + file.split(".py")[0])
def _delete_session(self, id): try: del self.sessions[id] self.current_session.close() custom_print.info("Session %s has been closed" % str(id)) except: custom_print.error("Error deleting session " + str(id))
def run(): try: Shell().start() except KeyboardInterrupt: print("[!!] Bye BoomER") try: exit(0) except SystemExit: _exit(0) except Exception as e: error("Something was wrong...") error(e)
def interact(self, session_id): try: session_id = int(session_id) client = self.sessions[session_id][0] self.current_session = client pl = (self.sessions[session_id][1]).lower() if "linux" in pl: self.module_session = Linux(self, self.current_session) custom_print.info("Interacting with: " + pl) elif "windows" in pl: self.module_session = Windows(self, self.current_session) custom_print.info("Interacting with: " + pl) else: self.module_session = Mac(self, self.current_session) custom_print.info("Interacting with: " + pl) except Exception as e: print(e) print("Session no found") return self.completer.set_backup() self.completer.set_all_commands(list(self.module_session.get_functions().keys()),[]) while True: try: data_input = input(color.YELLOW + "BoomERpreter >> " + color.RESET) data_input = data_input.strip() if data_input == "": continue if "exit" in data_input: self.completer.restore_backup() self._delete_session(session_id) return if "background" in data_input: custom_print.info("Session %s to background"%str(session_id)) self.completer.restore_backup() return 1 split_data = data_input.split() opt = self.module_session.get_functions()[split_data[0]] if not opt: continue if not opt["exec"]: getattr(self.module_session, opt["function"])() continue getattr(self.module_session, opt["function"])(split_data) except KeyboardInterrupt: self.completer.restore_backup() self._delete_session(session_id) return 0 except Exception as e: custom_print.error(str(e)) if "Broken pipe" in str(e): custom_print.info("Meterpreter closed") self._delete_session(session_id) return 0
def load(self, module): try: self.completer.remove_options(self.myModule.get_all_operations()) except: pass module_load = loadModule(module) if (module_load is None): custom_print.error("Error loading module") return None custom_print.ok(str(module) + " loaded correctly") self.nameModule = module self.myModule = module_load try: self.completer.extend_completer(self.myModule.get_all_operations()) except Exception as e: print(e)
def check_vuln(self, data): try: check = DATA_CHECK[data[1]] except: custom_print.info("This app can not be verified") return to_check = check["command"] self.send_msg(["check_vuln", to_check], True) result = self.recv_msg() success = False for values in check["versions"]: data = list(values.items()) if data[0][0] in result: custom_print.ok("Vulnerable! " + data[0][1]) success = True if not success: custom_print.error("No vulnerable")
def treat_input(self): operation = "" while True: if (self.myModule is None): operation = input(self.prompt()) else: #to get name module ml = self.nameModule.split(sep) operation = input(self.prompt(ml[len(ml) - 1])) op = operation.strip() op = self.strip_own(op) if (len(op) == 0): continue op[0] = op[0].lower() if (op[0] == "exit"): print("Closing BoomER") exit(0) try: self.exec_command(op) except Exception as e: custom_print.error(e)
def exec_command(self, op): if op[0] == "search": if len(op) == 1: custom_print.error("What do you want to search?") else: Search().search(op[1:]) elif op[0] == "back": self.back() elif op[0] == "clear": self.clear() elif op[0] in self._options_start.keys(): if len(op) == 1: getattr(self, op[0])() elif len(op) >= 2: getattr(self, op[0])(op[1]) else: if not self.myModule: raise Exception("Command " + op[0] + " not found. Try to load a module") else: if op[0] in self.myModule.get_single_operations(): # before run --> check if all options have a correct value if op[0] == "run": self.myModule.check_module() getattr(self.myModule, op[0])() elif op[0] in self.myModule.get_parameter_operations(): if len(op) >= 2: getattr(self.myModule, op[0])(op[1]) else: raise Exception("positional argument") elif op[0] in self.myModule.get_multiple_parameter_operations( ): if len(op) >= 2: getattr(self.myModule, op[0])(op[1:]) else: raise Exception("positional argument") else: raise Exception("Command " + op[0] + " not found")
def interact(self, id=None): if not id: custom_print.error("It's necessary an ID") return self.open_sessions.interact(id)
def put(self, key, value): try: self.options[key][1] = value custom_print.info(key + " => " + value) except: custom_print.error("Wrong option: " + key)