Exemple #1
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)
Exemple #2
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')
Exemple #3
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")
Exemple #4
0
    def list(self) -> None:
        """
        Display list of current proxy chains

        Usage: list
        """
        proxies = list(
            map(
                lambda x: [
                    self.proxy_list.index(x) + 1,
                    x["addr"],
                    x["port"],
                    x["proxytype"],
                ],
                self.proxy_list,
            )
        )
        proxies.insert(0, ["Hop", "Address", "Port", "Proxy Type"])

        table_util.print_table(proxies, "Active Proxies")
Exemple #5
0
    def user_list(self) -> None:
        """
        Display all Empire user accounts

        Usage: user_list
        """
        users_list = []

        for user in state.get_users()['users']:
            users_list.append([
                str(user['ID']), user['username'],
                str(user['admin']),
                str(user['enabled']),
                date_util.humanize_datetime(user['last_logon_time'])
            ])

        users_list.insert(
            0, ['ID', 'Username', 'Admin', 'Enabled', 'Last Logon Time'])

        table_util.print_table(users_list, 'Users')
Exemple #6
0
    def view(self, task_id: str):
        """
        View specific task and result

        Usage: view <task_id>
        """
        task = state.get_agent_task(self.session_id, task_id)
        record_list = []
        for key, value in task.items():
            # If results exceed a certain length they break the table function
            if key != 'results':
                record_list.append([print_util.color(key, 'blue'), value])
        table_util.print_table(record_list,
                               'View Task',
                               colored_header=False,
                               no_borders=True,
                               end_space=False)
        print(print_util.color(" results", "blue"))
        for line in task['results'].split('\n'):
            print(print_util.color(line))
Exemple #7
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")
Exemple #8
0
    def user_list(self) -> None:
        """
        Display all Empire user accounts

        Usage: user_list
        """
        users_list = []

        for user in state.get_users()["users"]:
            users_list.append([
                str(user["ID"]),
                user["username"],
                str(user["admin"]),
                str(user["enabled"]),
                date_util.humanize_datetime(user["last_logon_time"]),
            ])

        users_list.insert(
            0, ["ID", "Username", "Admin", "Enabled", "Last Logon Time"])

        table_util.print_table(users_list, "Users")
Exemple #9
0
    def list(self) -> None:
        """
        Get running/available agents

        Usage: list
        """
        cred_list = list(
            map(
                lambda x: [
                    x["ID"],
                    x["credtype"],
                    x["domain"],
                    x["username"],
                    x["host"],
                    x["password"][:50],
                    x["sid"],
                    x["os"],
                    x["notes"],
                ],
                state.get_credentials(),
            )
        )
        cred_list.insert(
            0,
            [
                "ID",
                "CredType",
                "Domain",
                "UserName",
                "Host",
                "Password/Hash",
                "SID",
                "OS",
                "Notes",
            ],
        )

        table_util.print_table(cred_list, "Credentials")
Exemple #10
0
    def list(self) -> None:
        """
        Get running/available listeners

        Usage: list
        """
        listener_list = list(
            map(
                lambda x: [
                    x["ID"],
                    x["name"],
                    x["module"],
                    x["listener_category"],
                    date_util.humanize_datetime(x["created_at"]),
                    x["enabled"],
                ],
                state.listeners.values(),
            ))
        listener_list.insert(0, [
            "ID", "Name", "Module", "Listener Category", "Created At",
            "Enabled"
        ])

        table_util.print_table(listener_list, "Listeners List")
    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')