def command_use(self, module_path, *args, **kwargs): module_path = utils.pythonize_path(module_path) module_path = '.'.join(('routersploit', 'modules', module_path)) # module_path, _, exploit_name = module_path.rpartition('.') try: self.current_module = utils.import_exploit(module_path)() except RoutersploitException as err: utils.print_error(err.message)
def command_use(self, module_path, *args, **kwargs): module_path = utils.pythonize_path(module_path) module_path = '.'.join(('routersploit', 'modules', module_path)) # module_path, _, exploit_name = module_path.rpartition('.') try: module = importlib.import_module(module_path) self.current_module = getattr(module, 'Exploit')() except (ImportError, AttributeError, KeyError): utils.print_error("Error during loading '{}' module".format(utils.humanize_path(module_path)))
def command_use(self, module_path, *args, **kwargs): module_path = utils.pythonize_path(module_path) module_path = '.'.join(('routersploit', 'modules', module_path)) # module_path, _, exploit_name = module_path.rpartition('.') try: module = importlib.import_module(module_path) self.current_module = getattr(module, 'Exploit')() except (ImportError, AttributeError, KeyError): utils.print_error("Error during loading '{}' module".format( utils.humanize_path(module_path)))
def available_modules_completion(self, text): """ Looking for tab completion hints using setup.py entry_points. May need optimization in the future! :param text: argument of 'use' command :return: list of tab completion hints """ text = utils.pythonize_path(text) all_possible_matches = filter(lambda x: x.startswith(text), self.modules) matches = set() for match in all_possible_matches: head, sep, tail = match[len(text):].partition('.') if not tail: sep = "" matches.add("".join((text, head, sep))) return list(map(utils.humanize_path, matches)) # humanize output, replace dots to forward slashes