Пример #1
0
    def list(self) -> None:
        """
        Get running/available agents

        Usage: list
        """
        agent_list = []
        agent_formatting = []
        for agent in state.get_agents().values():
            agent_list.append([
                str(agent['ID']), agent['name'], agent['language'],
                agent['internal_ip'],
                print_util.text_wrap(agent['username']),
                print_util.text_wrap(agent['process_name'],
                                     width=20), agent['process_id'],
                str(agent['delay']) + '/' + str(agent['jitter']),
                print_util.text_wrap(date_util.humanize_datetime(
                    agent['lastseen_time']),
                                     width=25), agent['listener']
            ])
            agent_formatting.append([agent['stale'], agent['high_integrity']])

        agent_formatting.insert(0, ['Stale', 'High Integrity'])
        agent_list.insert(0, [
            'ID', 'Name', 'Language', 'Internal IP', 'Username', 'Process',
            'PID', 'Delay', 'Last Seen', 'Listener'
        ])
        table_util.print_agent_table(agent_list, agent_formatting, 'Agents')
Пример #2
0
    def help(self):
        """
        Display the help menu for the current menu

        Usage: help
        """
        help_list = []
        for name in self._cmd_registry:
            try:
                description = print_util.text_wrap(getattr(
                    self, name).__doc__.split('\n')[1].lstrip(),
                                                   width=35)
                usage = print_util.text_wrap(getattr(
                    self, name).__doc__.split('\n')[3].lstrip()[7:],
                                             width=35)
                help_list.append([name, description, usage])
            except:
                continue

        for name, shortcut in shortcut_handler.shortcuts[
                self.agent_language].items():
            try:
                description = shortcut.get_help_description()
                usage = shortcut.get_usage_string()
                help_list.append([name, description, usage])
            except:
                continue
        help_list.insert(0, ['Name', 'Description', 'Usage'])
        table_util.print_table(help_list, 'Help Options')
Пример #3
0
    def get_help_description(self) -> str:
        if self.shell:
            return print_util.text_wrap(f"Tasks an agent to run the shell command '{self.shell}'")

        module = self.module
        default_params = list(map(lambda x: f"{x.name}: {x.value}", self.get_static_params()))
        description = f"Tasks the agent to run module {module}."
        if len(default_params) > 0:
            description += ' Default parameters include:\n'
            description += '\n'.join(default_params)

        return print_util.text_wrap(description)
Пример #4
0
    def help(self):
        """
        Display the help menu for the current menu

        Usage: help
        """
        help_list = []
        for name in self._cmd_registry:
            try:
                description = print_util.text_wrap(getattr(
                    self, name).__doc__.split("\n")[1].lstrip(),
                                                   width=35)
                usage = print_util.text_wrap(getattr(
                    self, name).__doc__.split("\n")[3].lstrip()[7:],
                                             width=35)
                help_list.append([name, description, usage])
            except:
                continue

        # Update help menu with other menus
        help_list.append(["listeners", "View all listeners.", "listeners"])
        help_list.append([
            "uselisteners", "Use an Empire listener.",
            "uselisteners <listener_name>"
        ])
        help_list.append(
            ["usestager", "Use an Empire stager.", "usestager <stager_name>"])
        help_list.append(
            ["useplugin", "Use an Empire plugin.", "useplugin <plugin_name>"])
        help_list.append([
            "usecredential", "View and edit an credential.",
            "usecredential <cred_id>"
        ])
        help_list.append(["plugins", "View active plugins menu.", "plugins"])
        help_list.append(["agents", "View all agents.", "agents"])
        help_list.append(
            ["usemodule", "Use an Empire module.", "usemodule <module_name>"])
        help_list.append([
            "credentials",
            "Add/display credentials to/from the database.",
            "credentials",
        ])
        help_list.append(["admin", "View admin menu", "admin"])
        help_list.append([
            "interact", "Interact with active agents.", "interact <agent_name>"
        ])
        help_list.append(["sponsors", "List of Empire sponsors.", "sponsors"])

        help_list.sort()
        help_list.insert(0, ["Name", "Description", "Usage"])
        table_util.print_table(help_list, "Help Options")
Пример #5
0
    def help(self):
        """
        Display the help menu for the current menu

        Usage: help
        """
        help_list = []
        for name in self._cmd_registry:
            try:
                description = print_util.text_wrap(getattr(
                    self, name).__doc__.split('\n')[1].lstrip(),
                                                   width=35)
                usage = print_util.text_wrap(getattr(
                    self, name).__doc__.split('\n')[3].lstrip()[7:],
                                             width=35)
                help_list.append([name, description, usage])
            except:
                continue

        # Update help menu with other menus
        help_list.append(['listeners', 'View all listeners.', 'listeners'])
        help_list.append([
            'uselisteners', 'Use an Empire listener.',
            'uselisteners <listener_name>'
        ])
        help_list.append(
            ['usestager', 'Use an Empire stager.', 'usestager <stager_name>'])
        help_list.append(
            ['useplugin', 'Use an Empire plugin.', 'useplugin <plugin_name>'])
        help_list.append([
            'usecredential', 'View and edit an credential.',
            'usecredential <cred_id>'
        ])
        help_list.append(['plugins', 'View active plugins menu.', 'plugins'])
        help_list.append(['agents', 'View all agents.', 'agents'])
        help_list.append(
            ['usemodule', 'Use an Empire module.', 'usemodule <module_name>'])
        help_list.append([
            'credentials', 'Add/display credentials to/from the database.',
            'credentials'
        ])
        help_list.append(['admin', 'View admin menu', 'admin'])
        help_list.append([
            'interact', 'Interact with active listeners.',
            'interact <agent_name>'
        ])

        help_list.sort()
        help_list.insert(0, ['Name', 'Description', 'Usage'])
        table_util.print_table(help_list, 'Help Options')
Пример #6
0
    def options(self):
        """
        Print the current record options

        Usage: options
        """
        record_list = []
        for key, value in self.record_options.items():
            name = key
            record_value = print_util.text_wrap(value.get('Value', ''))
            required = print_util.text_wrap(value.get('Required', ''))
            description = print_util.text_wrap(value.get('Description', ''))
            record_list.append([name, record_value, required, description])

        record_list.insert(0, ['Name', 'Value', 'Required', 'Description'])

        table_util.print_table(record_list, 'Record Options')
Пример #7
0
    def options(self):
        """
        Print the current record options

        Usage: options
        """
        record_list = []
        for key, value in self.record_options.items():
            name = key
            record_value = print_util.text_wrap(value.get("Value", ""))
            required = print_util.text_wrap(value.get("Required", ""))
            description = print_util.text_wrap(value.get("Description", ""))
            record_list.append([name, record_value, required, description])

        record_list.insert(0, ["Name", "Value", "Required", "Description"])

        table_util.print_table(record_list, "Record Options")
Пример #8
0
    def list(self) -> None:
        """
        Get running/available agents

        Usage: list
        """
        agent_list = []
        agent_formatting = []
        for agent in state.get_agents().values():
            agent_list.append([
                str(agent["ID"]),
                agent["name"],
                agent["language"],
                agent["internal_ip"],
                print_util.text_wrap(agent["username"]),
                print_util.text_wrap(agent["process_name"], width=20),
                agent["process_id"],
                str(agent["delay"]) + "/" + str(agent["jitter"]),
                print_util.text_wrap(date_util.humanize_datetime(
                    agent["lastseen_time"]),
                                     width=25),
                agent["listener"],
            ])
            agent_formatting.append([agent["stale"], agent["high_integrity"]])

        agent_formatting.insert(0, ["Stale", "High Integrity"])
        agent_list.insert(
            0,
            [
                "ID",
                "Name",
                "Language",
                "Internal IP",
                "Username",
                "Process",
                "PID",
                "Delay",
                "Last Seen",
                "Listener",
            ],
        )
        table_util.print_agent_table(agent_list, agent_formatting, "Agents")
Пример #9
0
    def info(self):
        """"
        Print default info on the current record.

        Usage: info
        """
        record_list = []

        for key, values in self.record.items():
            if (key in [
                    'Name', 'Author', 'Comments', 'Description', 'Language',
                    'Background', 'NeedsAdmin', 'OpsecSafe', 'Techniques',
                    'Software'
            ]):
                if isinstance(values, list):
                    if len(values) > 0 and values[0] != '':
                        for i, value in enumerate(values):
                            if key == 'Techniques':
                                value = 'http://attack.mitre.org/techniques/' + value
                            if i == 0:
                                record_list.append([
                                    print_util.color(key, 'blue'),
                                    print_util.text_wrap(value, width=70)
                                ])
                            else:
                                record_list.append([
                                    '',
                                    print_util.text_wrap(value, width=70)
                                ])
                elif values != '':
                    if key == 'Software':
                        values = 'http://attack.mitre.org/software/' + values

                    record_list.append([
                        print_util.color(key, 'blue'),
                        print_util.text_wrap(values, width=70)
                    ])

        table_util.print_table(record_list,
                               'Record Info',
                               colored_header=False,
                               no_borders=True)
Пример #10
0
    def options(self, listener_name: str) -> None:
        """
        Get option details for the selected listener

        Usage: options <listener_name>
        """
        if listener_name not in state.listeners:
            return None

        record_list = []
        for key, value in state.listeners[listener_name]['options'].items():
            name = key
            record_value = print_util.text_wrap(value.get('Value', ''))
            required = print_util.text_wrap(value.get('Required', ''))
            description = print_util.text_wrap(value.get('Description', ''))
            record_list.append([name, record_value, required, description])

        record_list.insert(0, ['Name', 'Value', 'Required', 'Description'])

        table_util.print_table(record_list, 'Record Options')
Пример #11
0
    def options(self, listener_name: str) -> None:
        """
        Get option details for the selected listener

        Usage: options <listener_name>
        """
        if listener_name not in state.listeners:
            return None

        record_list = []
        for key, value in state.listeners[listener_name]["options"].items():
            name = key
            record_value = print_util.text_wrap(value.get("Value", ""))
            required = print_util.text_wrap(value.get("Required", ""))
            description = print_util.text_wrap(value.get("Description", ""))
            record_list.append([name, record_value, required, description])

        record_list.insert(0, ["Name", "Value", "Required", "Description"])

        table_util.print_table(record_list, "Record Options")
Пример #12
0
    def help(self):
        """
        Display the help menu for the current menu

        Usage: help
        """
        help_list = []
        for name in self._cmd_registry:
            try:
                description = print_util.text_wrap(getattr(
                    self, name).__doc__.split("\n")[1].lstrip(),
                                                   width=35)
                usage = print_util.text_wrap(getattr(
                    self, name).__doc__.split("\n")[3].lstrip()[7:],
                                             width=35)
                help_list.append([name, description, usage])
            except:
                continue

        help_list.insert(0, ["Name", "Description", "Usage"])
        table_util.print_table(help_list, "Help Options")