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']), date_util.humanize_datetime(agent['lastseen_time']), 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')
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)
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')
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 values[0] != '': for i, value in enumerate(values): if i == 0: record_list.append([print_util.color(key, 'blue'), print_util.text_wrap(value, width=40)]) else: record_list.append(['', print_util.text_wrap(value)]) elif values != '': record_list.append([print_util.color(key, 'blue'), print_util.text_wrap(values, width=40)]) table_util.print_table(record_list, 'Record Info', colored_header=False, no_borders=True)