def command_search(self, *args, **kwargs): keyword = args[0] if not keyword: print_error("Please specify search keyword. e.g. 'search cisco'") return for module in self.modules: if keyword in module: module = humanize_path(module) print_info( "{}\033[31m{}\033[0m{}".format(*module.partition(keyword)))
def command_search(self, *args, **kwargs): keyword = args[0] if not keyword: print_error("Please specify search keyword. e.g. 'search cisco'") return for module in self.modules: if keyword in module: module = humanize_path(module) print_info( "{}\033[31m{}\033[0m{}".format(*module.partition(keyword)) )
def import_engine(path: str): """ Import Search engine :param str path: engine python path :return: Search module """ try: module = importlib.import_module(path) if hasattr(module, "Search"): return getattr(module, "Search")() else: raise ImportError("No module named '{}'".format(path)) except (ImportError, AttributeError, KeyError) as err: raise RoutersploitException("Error during loading '{}'\n\n" "Error: {}\n\n".format( humanize_path(path), err))
def command_search(self, *args, **kwargs): mod_type = '' mod_detail = '' mod_vendor = '' existing_modules = [ name for _, name, _ in pkgutil.iter_modules([MODULES_DIR]) ] devices = [ name for _, name, _ in pkgutil.iter_modules( [os.path.join(MODULES_DIR, 'exploits')]) ] languages = [ name for _, name, _ in pkgutil.iter_modules( [os.path.join(MODULES_DIR, 'encoders')]) ] payloads = [ name for _, name, _ in pkgutil.iter_modules( [os.path.join(MODULES_DIR, 'payloads')]) ] try: keyword = args[0].strip("'\"").lower() except IndexError: keyword = '' if not (len(keyword) or len(kwargs.keys())): print_error( "Please specify at least search keyword. e.g. 'search cisco'") print_error( "You can specify options. e.g. 'search type=exploits device=routers vendor=linksys WRT100 rce'" ) return for (key, value) in kwargs.items(): if key == 'type': if value not in existing_modules: print_error("Unknown module type.") return # print_info(' - Type :\t{}'.format(value)) mod_type = "{}.".format(value) elif key in ['device', 'language', 'payload']: if key == 'device' and (value not in devices): print_error("Unknown exploit type.") return elif key == 'language' and (value not in languages): print_error("Unknown encoder language.") return elif key == 'payload' and (value not in payloads): print_error("Unknown payload type.") return # print_info(' - {}:\t{}'.format(key.capitalize(), value)) mod_detail = ".{}.".format(value) elif key == 'vendor': # print_info(' - Vendor:\t{}'.format(value)) mod_vendor = ".{}.".format(value) for module in self.modules: if mod_type not in str(module): continue if mod_detail not in str(module): continue if mod_vendor not in str(module): continue if not all(word in str(module) for word in keyword.split()): continue found = humanize_path(module) if len(keyword): for word in keyword.split(): found = found.replace(word, "\033[31m{}\033[0m".format(word)) print_info(found)