Exemplo n.º 1
0
    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'])))

        # todo can we use asyncio?
        agent_return = threading.Thread(target=self.tasking_id_returns, args=[self.session_id, response['taskID']])
        agent_return.daemon = True
        agent_return.start()
Exemplo n.º 2
0
    def python_update_directory(self, agent_name: str):
        """
        Update current directory

        Usage:  update_directory <agent_name>
        """
        temp_name = None
        task_id: str = str(
            state.agent_shell(agent_name, 'echo $PWD')['taskID'])

        # Retrieve directory results and wait for response
        while temp_name is None:
            try:
                temp_name = state.get_task_result(
                    agent_name, task_id)['results'].split('\r')[0]
            except:
                pass
            time.sleep(1)
        self.display_name = temp_name
        self.get_prompt()
Exemplo n.º 3
0
    def powershell_update_directory(self, agent_name: str):
        """
        Update current directory

        Usage:  update_directory <agent_name>
        """
        temp_name = None
        task_id: str = str(
            state.agent_shell(agent_name, '(Resolve-Path .\).Path')['taskID'])

        # Retrieve directory results and wait for response
        while temp_name is None:
            try:
                temp_name = state.get_task_result(agent_name,
                                                  task_id)['results']
            except:
                pass
            time.sleep(1)
        self.display_name = temp_name
        self.get_prompt()
Exemplo n.º 4
0
    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']:
            if self.language == 'powershell':
                shell_return = threading.Thread(
                    target=self.powershell_update_directory, args=[agent_name])
                shell_return.daemon = True
                shell_return.start()
            elif self.language == 'python':
                shell_return = threading.Thread(
                    target=self.python_update_directory, args=[agent_name])
                shell_return.daemon = True
                shell_return.start()
        else:
            shell_return = threading.Thread(
                target=self.tasking_id_returns,
                args=[self.selected, response['taskID']])
            shell_return.daemon = True
            shell_return.start()