def update_directory(self, session_id: str): """ Update current directory """ if self.language == 'powershell': task_id: int = state.agent_shell( session_id, '(Resolve-Path .\).Path')['taskID'] elif self.language == 'python': task_id: int = state.agent_shell(session_id, 'echo $PWD')['taskID'] elif self.language == 'csharp': task_id: int = state.agent_shell( session_id, '(Resolve-Path .\).Path')['taskID'] pass count = 0 result = None while result is None and count < 30: result = state.cached_agent_results.get(session_id, {}).get(task_id) count += 1 time.sleep(1) if result: temp_name = result.split('\r')[0] del state.cached_agent_results.get(session_id, {})[task_id] self.display_name = temp_name self.get_prompt()
def update_directory(self, session_id: str): """ Update current directory """ if self.language == "powershell": task_id: int = state.agent_shell(session_id, "(Resolve-Path .\).Path")[ "taskID" ] elif self.language == "python": task_id: int = state.agent_shell(session_id, "echo $PWD")["taskID"] elif self.language == "ironpython": task_id: int = state.agent_shell(session_id, "cd .")["taskID"] elif self.language == "csharp": task_id: int = state.agent_shell(session_id, "(Resolve-Path .\).Path")[ "taskID" ] pass count = 0 result = None while result is None and count < 30: result = state.cached_agent_results.get(session_id, {}).get(task_id) count += 1 time.sleep(1) if result: temp_name = result.split("\r")[0] del state.cached_agent_results.get(session_id, {})[task_id] self.display_name = temp_name self.get_prompt()
def shell(self, shell_cmd: str) -> None: """ Tasks an the specified agent to execute a shell command. Usage: shell <shell_cmd> """ response = state.agent_shell(self.session_id, shell_cmd) print(print_util.color('[*] Tasked ' + self.session_id + ' to run Task ' + str(response['taskID'])))
def shell(self, agent_name: str, shell_cmd: str): """ Tasks an the specified agent_name to execute a shell command. Usage: <shell_cmd> """ response = state.agent_shell(agent_name, shell_cmd) if shell_cmd.split()[0].lower() in ['cd', 'set-location']: shell_return = threading.Thread(target=self.update_directory, args=[agent_name]) shell_return.daemon = True shell_return.start() else: shell_return = threading.Thread(target=self.tasking_id_returns, args=[response['taskID']]) shell_return.daemon = True shell_return.start()