Esempio n. 1
0
    def __init__(self, module_directory=paths.POCSUITE_POCS_PATH):
        super(PocsuiteInterpreter, self).__init__()

        self.current_module = None
        self.raw_prompt_template = None
        self.module_prompt_template = None
        self.prompt_hostname = "Pocsuite3"
        self.show_sub_commands = ("info", "options", "ip", "all")

        self.global_commands = sorted(
            ["use ", "help", "exit", "show ", "search ", "clear"])
        self.module_commands = ["run", "back", "set ", "setg ", "check"]
        self.module_commands.extend(self.global_commands)
        self.module_commands.sort()

        self.modules = index_modules(module_directory)
        self.module_parent_directory = os.sep.join(
            module_directory.rstrip(os.sep).split(os.sep)[0:-1]) + os.sep
        self.modules_count = len(self.modules)
        # init
        conf.console_mode = True
        banner()
        logger.info("Load Pocs :{}".format(self.modules_count))

        self.last_search = []
        self.last_ip = []
        self.main_modules_dirs = []
        for module in self.modules:
            temp_module = module
            temp_module = ltrim(temp_module,
                                self.module_parent_directory).lstrip(os.sep)
            self.main_modules_dirs.append(temp_module)

        self.__parse_prompt()
Esempio n. 2
0
 def command_use(self, module_path, *args, **kwargs):
     if module_path.isdigit():
         index = int(module_path)
         if index >= len(self.last_search):
             logger.warning("Index out of range")
             return
         module_path = self.last_search[index]
     if not module_path.endswith(".py"):
         module_path = module_path + ".py"
     if not os.path.exists(module_path):
         module_path = os.path.join(paths.POCSUITE_ROOT_PATH, module_path)
         if not os.path.exists(module_path):
             errMsg = "No such file: '{0}'".format(module_path)
             logger.error(errMsg)
             return
     try:
         load_file_to_module(module_path)
         self.current_module = kb.current_poc
         self.current_module.pocsuite3_module_path = ltrim(rtrim(module_path, ".py"),
                                                           os.path.join(paths.POCSUITE_ROOT_PATH, ""))
     except Exception as err:
         logger.error(str(err))