def command_use(self, module_path, *args, **kwargs): module_path = pythonize_path(module_path) module_path = ".".join(("routersploit", "modules", module_path)) # module_path, _, exploit_name = module_path.rpartition('.') try: self.current_module = import_exploit(module_path)() except RoutersploitException as err: print_error(str(err))
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 = 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(humanize_path, matches)) # humanize output, replace dots to forward slashes