def handle_listener_connection(): _ = ["list", "select", "exit", "quit", "clear"] auto_completion(AUTOCOMPLETE_TYPE.POCSUITE, commands=_) while True: cmd = None cmd = input('shell>: ').strip() if not cmd: continue elif cmd.lower() in ("?", "help"): print_cmd_help() elif cmd.lower() == "clear": clear_history() data_to_stdout("[i] history cleared\n") save_history(AUTOCOMPLETE_TYPE.POCSUITE) elif cmd.lower() in ("x", "q", "exit", "quit"): raise PocsuiteShellQuitException elif cmd == "list": list_clients() elif "select" in cmd: client = get_client(cmd) if client is not None: send_shell_commands(client) else: save_history(AUTOCOMPLETE_TYPE.POCSUITE) load_history(AUTOCOMPLETE_TYPE.POCSUITE) data_to_stdout("Command Not Found... type ? for help.")
def send_shell_commands(client): auto_completion(AUTOCOMPLETE_TYPE.OS, OS.LINUX) while True: cmd = None try: address = client.address[0] cmd = input("{0}>: ".format(address)) if not cmd: continue elif cmd.lower() == "clear": clear_history() data_to_stdout("[i] history cleared\n") save_history(AUTOCOMPLETE_TYPE.POCSUITE) elif cmd.lower() in ("x", "q", "exit", "quit", "bye"): break client.conn.send(str.encode(cmd + '\n')) resp = poll_cmd_execute(client) data_to_stdout(resp) except Exception as ex: logger.error(str(ex)) data_to_stdout("Connection Lost\n") break
def setup(self): """ Initialization of third-party libraries Setting interpreter history. Setting appropriate completer function. :return: """ auto_completion(completion=AUTOCOMPLETE_TYPE.CONSOLE, console=self.complete)