Python terminaltables.AsciiTable() Examples

The following are 30 code examples of terminaltables.AsciiTable(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module terminaltables , or try the search function .
Example #1
Source File: spookflare.py    From SpookFlare with Apache License 2.0 6 votes vote down vote up
def do_info(self, line):
        print("\n \033[1m\033[94m[*]\033[0m Module Info\033[0m\n")
        print(''' This module is generate VBA macro loader
 payload with character substitution. The VBA macro
 reads real payload from spesific meta-data sections
 of file. Thus, a great advantage can be obtained
 against the security countermeasures in the target.
 Also payload will be triggered when user close the
 document. Working in this way is especially advantageous
 in analysis. Because run of macro code for when
 file opened is marked as malicious by the usage
 intensity. Using this module, the desired operating
 system commands can be executed on the target system.''')
        print("\n \033[1m\033[94m[*]\033[0m Module Options\033[0m")
        optionsValues = [
            ["Parameter", "Required", "Value", "Description"],
            ["CMD", "Yes", vbaCmdFile, "The file containing the payload command to run"],
            ["FTYPE", "Yes", vbaFileType, "File type of payload. Accepted: word, excel, powerpoint"],
            ["META", "Yes", vbaMetaName, "The metadata name to read payload. Accepted: Comments and Company (case sensetive)"]
        ]
        optTable = AsciiTable(optionsValues)
        optTable.outer_border = False
        optTable.inner_column_border = False
        optTable.justify_columns[1] = "center"
        print("\n" + optTable.table + "\n") 
Example #2
Source File: hyperparameters.py    From paperspace-python with ISC License 6 votes vote down vote up
def make_details_table(obj):
        data = (
            ("ID", obj["data"].get("handle")),
            ("Name", obj["data"]["templateHistory"]["params"].get("name")),
            ("Ports", obj["data"]["templateHistory"]["params"].get("ports")),
            ("Project ID", obj["data"]["templateHistory"]["params"].get("project_handle")),
            ("Tuning command", obj["data"]["templateHistory"]["params"].get("tuning_command")),
            ("Worker command", obj["data"]["templateHistory"]["params"].get("worker_command")),
            ("Worker container", obj["data"]["templateHistory"]["params"].get("worker_container")),
            ("Worker count", obj["data"]["templateHistory"]["params"].get("worker_count")),
            ("Worker machine type", obj["data"]["templateHistory"]["params"].get("worker_machine_type")),
            ("Worker use dockerfile", obj["data"]["templateHistory"]["params"].get("worker_use_dockerfile")),
            ("Workspace URL", obj["data"]["templateHistory"]["params"].get("workspaceUrl")),
        )
        ascii_table = terminaltables.AsciiTable(data)
        table_string = ascii_table.table
        return table_string 
Example #3
Source File: new_ams.py    From pade with MIT License 6 votes vote down vote up
def on_time(self):
        super(ComportVerifyConnTimed, self).on_time()
        desconnect_agents = list()
        table = list([['agent', 'delta']])
        for agent_name, date in self.agent.agents_conn_time.items():
            now = datetime.now()
            delta = now - date
            table.append([agent_name, str(delta.total_seconds())])
            if delta.total_seconds() > 20.0:
                desconnect_agents.append(agent_name)
                self.agent.agentInstance.table.pop(agent_name)
                display_message(self.agent.aid.name, 'Agent {} disconnected.'.format(agent_name))    

        for agent_name in desconnect_agents:
            self.agent.agents_conn_time.pop(agent_name)

        if self.agent.debug:
            display_message(self.agent.aid.name, 'Calculating response time of the agents...')
            table = AsciiTable(table)
            print(table.table) 
Example #4
Source File: spookflare.py    From SpookFlare with Apache License 2.0 6 votes vote down vote up
def do_info(self, line):
        print("\n \033[1m\033[94m[*]\033[0m Module Info\033[0m\n")
        print(''' This module can be used to generate .EXE loaders and it is
 coded with C#. It support Meterpreter Reverse HTTP,
 Reverse HTTPS staged payloads. The payloads generated by
 this module has two parts. The first part is the real loader
 code generated with character substitution. The second part
 is to compile and run the first part at runtime.''')
        print("\n \033[1m\033[94m[*]\033[0m Module Options\033[0m")
        optionsValues = [
            ["Parameter", "Required", "Value", "Description"],
            ["PROTO", "Yes", mpbProto, "Listener protocol. Accepted: http or https"],
            ["LHOST", "Yes", mpbLhost, "The local listener hostname or IP address"],
            ["LPORT", "Yes", mpbLport, "The local listener port."],
            ["ARCH", "Yes", mpbArch, "Architecture of target system. Accepted: x86 or x64"],
            ["SSIZE", "No", mpbSsize, "If you patched Metasploit insert your patch size"]
        ]
        optTable = AsciiTable(optionsValues)
        optTable.outer_border = False
        optTable.inner_column_border = False
        optTable.justify_columns[1] = "center"
        print("\n" + optTable.table + "\n") 
Example #5
Source File: guilds.py    From bot with MIT License 6 votes vote down vote up
def listguilds(self, ctx):
        if not self.bot.isadmin(ctx.author):
            return await ctx.error('no')
        data = [
            ['Name', 'ID', 'Members', 'Channels', 'Boosts', 'Shard', 'Public']
        ]
        for guild in sorted(self.bot.guilds, key=lambda g: g.member_count, reverse=True):
            data.append([
                shorten(guild.name),
                guild.id,
                format(guild.member_count, ',d'),
                len(guild.channels),
                guild.premium_subscription_count,
                guild.shard_id,
                'PUBLIC' in guild.features
            ])
        table = AsciiTable(data)
        header = table.table.split('\n')[:3]
        paginator = WrappedPaginator(prefix='```\n' + '\n'.join(header), suffix='```', max_size=1950)
        for ln in table.table.split('\n'):
            if ln not in header:
                paginator.add_line(ln)
        interface = PaginatorInterface(ctx.bot, paginator, owner=ctx.author)
        return await interface.send_to(ctx) 
Example #6
Source File: spookflare.py    From Slackor with GNU General Public License v3.0 6 votes vote down vote up
def do_info(self, line):
        print("\n \033[1m\033[94m[*]\033[0m Module Info\033[0m\n")
        print(''' This module can be used to generate .EXE loaders and it is
 coded with C#. It support Meterpreter Reverse HTTP,
 Reverse HTTPS staged payloads. The payloads generated by
 this module has two parts. The first part is the real loader
 code generated with character substitution. The second part
 is to compile and run the first part at runtime.''')
        print("\n \033[1m\033[94m[*]\033[0m Module Options\033[0m")
        optionsValues = [
            ["Parameter", "Required", "Value", "Description"],
            ["PROTO", "Yes", mpbProto, "Listener protocol. Accepted: http or https"],
            ["LHOST", "Yes", mpbLhost, "The local listener hostname or IP address"],
            ["LPORT", "Yes", mpbLport, "The local listener port."],
            ["ARCH", "Yes", mpbArch, "Architecture of target system. Accepted: x86 or x64"],
            ["SSIZE", "No", mpbSsize, "If you patched Metasploit insert your patch size"]
        ]
        optTable = AsciiTable(optionsValues)
        optTable.outer_border = False
        optTable.inner_column_border = False
        optTable.justify_columns[1] = "center"
        print("\n" + optTable.table + "\n") 
Example #7
Source File: spookflare.py    From SpookFlare with Apache License 2.0 6 votes vote down vote up
def do_info(self, line):
        print("\n \033[1m\033[94m[*]\033[0m Module Info\033[0m\n")
        print(''' This module can be used to generate HTA downloader
 payload with character substitution, obfuscation
 and encoding. The module has HTML file output and
 generated HTML file do all things dynamically at
 the client-side. Thus, a great advantage can be
 obtained against the security countermeasures
 in the target. The logic of this module is derived
 from NCC Group's Demiguise project and added
 JavaScript encoder. Using this module, the desired
 operating system commands can be executed on
 the target system.''')
        print("\n \033[1m\033[94m[*]\033[0m Module Options\033[0m")
        optionsValues = [
            ["Parameter", "Required", "Value", "Description"],
            ["FNAME", "Yes", htaDownloadName, "The file name that will appear when the payload is triggered. Ex: SpookFlare"],
            ["CMD", "Yes", htaCmdFile, "The file containing the payload command to run"]
        ]
        optTable = AsciiTable(optionsValues)
        optTable.outer_border = False
        optTable.inner_column_border = False
        optTable.justify_columns[1] = "center"
        print("\n" + optTable.table + "\n") 
Example #8
Source File: spookflare.py    From Slackor with GNU General Public License v3.0 6 votes vote down vote up
def do_info(self, line):
        print("\n \033[1m\033[94m[*]\033[0m Module Info\033[0m\n")
        print(''' This module can be used to generate HTA downloader
 payload with character substitution, obfuscation
 and encoding. The module has HTML file output and
 generated HTML file do all things dynamically at
 the client-side. Thus, a great advantage can be
 obtained against the security countermeasures
 in the target. The logic of this module is derived
 from NCC Group's Demiguise project and added
 JavaScript encoder. Using this module, the desired
 operating system commands can be executed on
 the target system.''')
        print("\n \033[1m\033[94m[*]\033[0m Module Options\033[0m")
        optionsValues = [
            ["Parameter", "Required", "Value", "Description"],
            ["FNAME", "Yes", htaDownloadName, "The file name that will appear when the payload is triggered. Ex: SpookFlare"],
            ["CMD", "Yes", htaCmdFile, "The file containing the payload command to run"]
        ]
        optTable = AsciiTable(optionsValues)
        optTable.outer_border = False
        optTable.inner_column_border = False
        optTable.justify_columns[1] = "center"
        print("\n" + optTable.table + "\n") 
Example #9
Source File: spookflare.py    From Slackor with GNU General Public License v3.0 6 votes vote down vote up
def do_info(self, line):
        print("\n \033[1m\033[94m[*]\033[0m Module Info\033[0m\n")
        print(''' This module is generate VBA macro loader
 payload with character substitution. The VBA macro
 reads real payload from spesific meta-data sections
 of file. Thus, a great advantage can be obtained
 against the security countermeasures in the target.
 Also payload will be triggered when user close the
 document. Working in this way is especially advantageous
 in analysis. Because run of macro code for when
 file opened is marked as malicious by the usage
 intensity. Using this module, the desired operating
 system commands can be executed on the target system.''')
        print("\n \033[1m\033[94m[*]\033[0m Module Options\033[0m")
        optionsValues = [
            ["Parameter", "Required", "Value", "Description"],
            ["CMD", "Yes", vbaCmdFile, "The file containing the payload command to run"],
            ["FTYPE", "Yes", vbaFileType, "File type of payload. Accepted: word, excel, powerpoint"],
            ["META", "Yes", vbaMetaName, "The metadata name to read payload. Accepted: Comments and Company (case sensetive)"]
        ]
        optTable = AsciiTable(optionsValues)
        optTable.outer_border = False
        optTable.inner_column_border = False
        optTable.justify_columns[1] = "center"
        print("\n" + optTable.table + "\n") 
Example #10
Source File: cli.py    From indico-plugins with MIT License 6 votes vote down vote up
def agents():
    """Lists the currently active agents"""
    print 'The following LiveSync agents are active:'
    agent_list = LiveSyncAgent.find().order_by(LiveSyncAgent.backend_name, db.func.lower(LiveSyncAgent.name)).all()
    table_data = [['ID', 'Name', 'Backend', 'Initial Export', 'Queue']]
    for agent in agent_list:
        initial = (cformat('%{green!}done%{reset}') if agent.initial_data_exported else
                   cformat('%{yellow!}pending%{reset}'))
        if agent.backend is None:
            backend_title = cformat('%{red!}invalid backend ({})%{reset}').format(agent.backend_name)
        else:
            backend_title = agent.backend.title
        table_data.append([unicode(agent.id), agent.name, backend_title, initial,
                           unicode(agent.queue.filter_by(processed=False).count())])
    table = AsciiTable(table_data)
    table.justify_columns[4] = 'right'
    print table.table
    if not all(a.initial_data_exported for a in agent_list):
        print
        print "You need to perform the initial data export for some agents."
        print cformat("To do so, run "
                      "%{yellow!}indico livesync initial_export %{reset}%{yellow}<agent_id>%{reset} for those agents.") 
Example #11
Source File: interfaces.py    From HoneyBot with MIT License 6 votes vote down vote up
def print_submission_status():
    """
    Prints a formatted table of submitted PCAPs
    """
    table = [['Capture MD5',
              'Capture Name',
              'Capture Start',
              'Capture End',
              'Upload Start',
              'Upload End',
              'Size',
              'Queued',
              'Analysis Started',
              'Analysis Completed',
              'Malicious',
              'Link']]
    table.extend(get_submissions_status())
    print(terminaltables.AsciiTable(table).table) 
Example #12
Source File: example1.py    From terminaltables with MIT License 6 votes vote down vote up
def main():
    """Main function."""
    title = 'Jetta SportWagen'

    # AsciiTable.
    table_instance = AsciiTable(TABLE_DATA, title)
    table_instance.justify_columns[2] = 'right'
    print(table_instance.table)
    print()

    # SingleTable.
    table_instance = SingleTable(TABLE_DATA, title)
    table_instance.justify_columns[2] = 'right'
    print(table_instance.table)
    print()

    # DoubleTable.
    table_instance = DoubleTable(TABLE_DATA, title)
    table_instance.justify_columns[2] = 'right'
    print(table_instance.table)
    print() 
Example #13
Source File: cli.py    From indico-plugins with MIT License 6 votes vote down vote up
def rooms(status=None):
    """Lists all Vidyo rooms"""

    room_query = VCRoom.find(type='vidyo')
    table_data = [['ID', 'Name', 'Status', 'Vidyo ID', 'Extension']]

    if status:
        room_query = room_query.filter(VCRoom.status == VCRoomStatus.get(status))

    for room in room_query:
        table_data.append([unicode(room.id), room.name, room.status.name,
                           unicode(room.data['vidyo_id']), unicode(room.vidyo_extension.extension)])

    table = AsciiTable(table_data)
    for col in (0, 3, 4):
        table.justify_columns[col] = 'right'
    print table.table 
Example #14
Source File: logger.py    From machina with MIT License 6 votes vote down vote up
def csv2table(filename, save_dir=None, output_filename='scores-table.txt'):
    with open(filename, newline='') as f:
        data = list(csv.reader(f))
        table = terminaltables.AsciiTable(data)
        table.inner_row_border = False
        table.CHAR_H_INNER_HORIZONTAL = '-'
        table.CHAR_OUTER_TOP_LEFT = ''
        table.CHAR_OUTER_TOP_RIGHT = ''
        table.CHAR_OUTER_TOP_HORIZONTAL = ''
        table.CHAR_OUTER_TOP_INTERSECT = ''
        table.CHAR_OUTER_BOTTOM_LEFT = '|'
        table.CHAR_OUTER_BOTTOM_RIGHT = '|'
        table.CHAR_OUTER_BOTTOM_HORIZONTAL = ' '
        table.CHAR_OUTER_BOTTOM_INTERSECT = '|'
        table.CHAR_H_OUTER_LEFT_INTERSECT = '|'
        table.CHAR_H_OUTER_RIGHT_INTERSECT = '|'
        output = table.table.lstrip().rstrip()

    if save_dir is None:
        save_dir = os.path.dirname(filename)
    with open(os.path.join(save_dir, output_filename), 'w') as f:
        f.write(output) 
Example #15
Source File: utils.py    From keep with MIT License 6 votes vote down vote up
def list_commands(ctx):
    table_data = [['Command', 'Description', 'Alias']]
    no_of_columns = len(table_data[0])

    commands = read_commands()
    for cmd, fields in commands.items():
        table_data.append(['$ ' + cmd, fields['desc'], fields['alias']])

    table = AsciiTable(table_data)
    max_width = table.table_width//3

    for i in range(len(table_data) - 1):
        for j in range(no_of_columns):
            data = table.table_data[i + 1][j]
            if len(data) > max_width:
                table.table_data[i + 1][j] = '\n'.join(wrap(data, max_width))

    table.inner_row_border = True
    print(table.table) 
Example #16
Source File: check_tap.py    From singer-tools with Apache License 2.0 6 votes vote down vote up
def print_summary(summary):

    print('The output is valid.')
    print('It contained {} messages for {} streams.'.format(
        summary.num_messages(), len(summary.streams)))
    print('')
    print('{:7} schema messages'.format(summary.num_schemas()))
    print('{:7} record messages'.format(summary.num_records()))
    print('{:7} state messages'.format(summary.num_states))
    print('')
    print('Details by stream:')
    headers = [['stream', 'records', 'schemas']]
    rows = [[s.name, s.num_records, s.num_schemas]
            for s in summary.streams.values()]
    data = headers + rows

    table = AsciiTable(data)
    print(table.table) 
Example #17
Source File: spookflare.py    From Slackor with GNU General Public License v3.0 5 votes vote down vote up
def do_info(self, line):
        print("\n \033[1m\033[94m[*]\033[0m Module Info\033[0m\n")
        print(''' This module can be used to generate PowerShell
 based loader (.PS1) and .EXE loader for blocked powershell.exe
 environments. It support Meterpreter Reverse HTTP, Reverse HTTPS
 staged payloads. The payload generated by this module has two output.
 The first output is PowerShell script and it can be used directly
 when available PowerShell access. The second output is C# code
 for PowerShell based loader code that will be used when powershell.exe
 is blocked. You can compile and run it, after that loader runs
 the PowerShell  based loader code using System.Management.Automation.dll.
 This module also has the ability to process patched stages.''')
        print("\n \033[1m\033[94m[*]\033[0m Module Options\033[0m")
        optionsValues = [
            ["Parameter", "Required", "Value", "Description"],
            ["PROTO", "Yes", mppProto, "Listener protocol. Accepted: http or https"],
            ["LHOST", "Yes", mppLhost, "The local listener hostname or IP address"],
            ["LPORT", "Yes", mppLport, "The local listener port."],
            ["ARCH", "Yes", mppArch, "Architecture of target system. Accepted: x86 or x64"],
            ["SSIZE", "No", mppSsize, "If you patched Metasploit insert your patch size"]
        ]
        optTable = AsciiTable(optionsValues)
        optTable.outer_border = False
        optTable.inner_column_border = False
        optTable.justify_columns[1] = "center"
        print("\n" + optTable.table + "\n") 
Example #18
Source File: recall.py    From kaggle-imaterialist with MIT License 5 votes vote down vote up
def print_recall_summary(recalls,
                         proposal_nums,
                         iou_thrs,
                         row_idxs=None,
                         col_idxs=None):
    """Print recalls in a table.

    Args:
        recalls(ndarray): calculated from `bbox_recalls`
        proposal_nums(ndarray or list): top N proposals
        iou_thrs(ndarray or list): iou thresholds
        row_idxs(ndarray): which rows(proposal nums) to print
        col_idxs(ndarray): which cols(iou thresholds) to print
    """
    proposal_nums = np.array(proposal_nums, dtype=np.int32)
    iou_thrs = np.array(iou_thrs)
    if row_idxs is None:
        row_idxs = np.arange(proposal_nums.size)
    if col_idxs is None:
        col_idxs = np.arange(iou_thrs.size)
    row_header = [''] + iou_thrs[col_idxs].tolist()
    table_data = [row_header]
    for i, num in enumerate(proposal_nums[row_idxs]):
        row = [
            '{:.3f}'.format(val)
            for val in recalls[row_idxs[i], col_idxs].tolist()
        ]
        row.insert(0, num)
        table_data.append(row)
    table = AsciiTable(table_data)
    print(table.table) 
Example #19
Source File: example_scan_access_points.py    From libnl with GNU Lesser General Public License v2.1 5 votes vote down vote up
def print_table(data):
    """Print the table of detected SSIDs and their data to screen.

    Positional arguments:
    data -- list of dictionaries.
    """
    table = AsciiTable([COLUMNS])
    table.justify_columns[2] = 'right'
    table.justify_columns[3] = 'right'
    table.justify_columns[4] = 'right'
    table_data = list()
    for row_in in data:
        row_out = [
            str(row_in.get('ssid', '')).replace('\0', ''),
            str(row_in.get('security', '')),
            str(row_in.get('channel', '')),
            str(row_in.get('frequency', '')),
            str(row_in.get('signal', '')),
            str(row_in.get('bssid', '')),
        ]
        if row_out[3]:
            row_out[3] += ' MHz'
        if row_out[4]:
            row_out[4] += ' dBm'
        table_data.append(row_out)

    sort_by_column = [c.lower() for c in COLUMNS].index(OPTIONS['--key'].lower())
    table_data.sort(key=lambda c: c[sort_by_column], reverse=OPTIONS['--reverse'])

    table.table_data.extend(table_data)
    print(table.table) 
Example #20
Source File: recall.py    From Cascade-RPN with Apache License 2.0 5 votes vote down vote up
def print_recall_summary(recalls,
                         proposal_nums,
                         iou_thrs,
                         row_idxs=None,
                         col_idxs=None):
    """Print recalls in a table.

    Args:
        recalls(ndarray): calculated from `bbox_recalls`
        proposal_nums(ndarray or list): top N proposals
        iou_thrs(ndarray or list): iou thresholds
        row_idxs(ndarray): which rows(proposal nums) to print
        col_idxs(ndarray): which cols(iou thresholds) to print
    """
    proposal_nums = np.array(proposal_nums, dtype=np.int32)
    iou_thrs = np.array(iou_thrs)
    if row_idxs is None:
        row_idxs = np.arange(proposal_nums.size)
    if col_idxs is None:
        col_idxs = np.arange(iou_thrs.size)
    row_header = [''] + iou_thrs[col_idxs].tolist()
    table_data = [row_header]
    for i, num in enumerate(proposal_nums[row_idxs]):
        row = [
            '{:.3f}'.format(val)
            for val in recalls[row_idxs[i], col_idxs].tolist()
        ]
        row.insert(0, num)
        table_data.append(row)
    table = AsciiTable(table_data)
    print(table.table) 
Example #21
Source File: spookflare.py    From Slackor with GNU General Public License v3.0 5 votes vote down vote up
def do_list(self, line):
        optionsValues = [
            ["ID", "Payload", "Description"],
            ["1", "meterpreter/binary", ".EXE Meterpreter Reverse HTTP and HTTPS loader"],
            ["2", "meterpreter/powershell", "PowerShell based Meterpreter Reverse HTTP and HTTPS loader"],
            ["3", "javascript/hta", ".HTA loader with .HTML extension for specific command"],
            ["4", "vba/macro", "Office Macro loader for specific command"]
        ]
        optTable = AsciiTable(optionsValues)
        optTable.outer_border = False
        optTable.inner_column_border = True
        print("\n" + optTable.table + "\n") 
Example #22
Source File: run.py    From apicheck with Apache License 2.0 5 votes vote down vote up
def list_apis(running_config: RunningConfig) -> APICheckException:
    """Save definition into database"""

    try:
        connection = await get_engine().connect()

        results = await connection.execute(APIMetadata.select())
        apis: list = await results.fetchall()

    except Exception as e:
        raise APICheckException(f"Error accessing to database: {e}")

    #
    # Adding Title
    #
    apis.insert(0, ("ID", "API Name", "Version"))

    # -------------------------------------------------------------------------
    # Printing results
    # -------------------------------------------------------------------------
    table_instance = AsciiTable(apis, "- API Info --")
    table_instance.justify_columns[0] = 'center'
    table_instance.justify_columns[1] = 'center'
    table_instance.justify_columns[2] = 'center'

    print()
    print(table_instance.table)
    print() 
Example #23
Source File: recall.py    From Libra_R-CNN with Apache License 2.0 5 votes vote down vote up
def print_recall_summary(recalls,
                         proposal_nums,
                         iou_thrs,
                         row_idxs=None,
                         col_idxs=None):
    """Print recalls in a table.

    Args:
        recalls(ndarray): calculated from `bbox_recalls`
        proposal_nums(ndarray or list): top N proposals
        iou_thrs(ndarray or list): iou thresholds
        row_idxs(ndarray): which rows(proposal nums) to print
        col_idxs(ndarray): which cols(iou thresholds) to print
    """
    proposal_nums = np.array(proposal_nums, dtype=np.int32)
    iou_thrs = np.array(iou_thrs)
    if row_idxs is None:
        row_idxs = np.arange(proposal_nums.size)
    if col_idxs is None:
        col_idxs = np.arange(iou_thrs.size)
    row_header = [''] + iou_thrs[col_idxs].tolist()
    table_data = [row_header]
    for i, num in enumerate(proposal_nums[row_idxs]):
        row = [
            '{:.3f}'.format(val)
            for val in recalls[row_idxs[i], col_idxs].tolist()
        ]
        row.insert(0, num)
        table_data.append(row)
    table = AsciiTable(table_data)
    print(table.table) 
Example #24
Source File: recall.py    From Feature-Selective-Anchor-Free-Module-for-Single-Shot-Object-Detection with Apache License 2.0 5 votes vote down vote up
def print_recall_summary(recalls,
                         proposal_nums,
                         iou_thrs,
                         row_idxs=None,
                         col_idxs=None):
    """Print recalls in a table.

    Args:
        recalls(ndarray): calculated from `bbox_recalls`
        proposal_nums(ndarray or list): top N proposals
        iou_thrs(ndarray or list): iou thresholds
        row_idxs(ndarray): which rows(proposal nums) to print
        col_idxs(ndarray): which cols(iou thresholds) to print
    """
    proposal_nums = np.array(proposal_nums, dtype=np.int32)
    iou_thrs = np.array(iou_thrs)
    if row_idxs is None:
        row_idxs = np.arange(proposal_nums.size)
    if col_idxs is None:
        col_idxs = np.arange(iou_thrs.size)
    row_header = [''] + iou_thrs[col_idxs].tolist()
    table_data = [row_header]
    for i, num in enumerate(proposal_nums[row_idxs]):
        row = [
            '{:.3f}'.format(val)
            for val in recalls[row_idxs[i], col_idxs].tolist()
        ]
        row.insert(0, num)
        table_data.append(row)
    table = AsciiTable(table_data)
    print(table.table) 
Example #25
Source File: recall.py    From RDSNet with Apache License 2.0 5 votes vote down vote up
def print_recall_summary(recalls,
                         proposal_nums,
                         iou_thrs,
                         row_idxs=None,
                         col_idxs=None):
    """Print recalls in a table.

    Args:
        recalls(ndarray): calculated from `bbox_recalls`
        proposal_nums(ndarray or list): top N proposals
        iou_thrs(ndarray or list): iou thresholds
        row_idxs(ndarray): which rows(proposal nums) to print
        col_idxs(ndarray): which cols(iou thresholds) to print
    """
    proposal_nums = np.array(proposal_nums, dtype=np.int32)
    iou_thrs = np.array(iou_thrs)
    if row_idxs is None:
        row_idxs = np.arange(proposal_nums.size)
    if col_idxs is None:
        col_idxs = np.arange(iou_thrs.size)
    row_header = [''] + iou_thrs[col_idxs].tolist()
    table_data = [row_header]
    for i, num in enumerate(proposal_nums[row_idxs]):
        row = [
            '{:.3f}'.format(val)
            for val in recalls[row_idxs[i], col_idxs].tolist()
        ]
        row.insert(0, num)
        table_data.append(row)
    table = AsciiTable(table_data)
    print(table.table) 
Example #26
Source File: spookflare.py    From SpookFlare with Apache License 2.0 5 votes vote down vote up
def do_info(self, line):
        print("\n \033[1m\033[94m[*]\033[0m Module Info\033[0m\n")
        print(''' This module can be used to generate PowerShell
 based loader (.PS1) and .EXE loader for blocked powershell.exe
 environments. It support Meterpreter Reverse HTTP, Reverse HTTPS
 staged payloads. The payload generated by this module has two output.
 The first output is PowerShell script and it can be used directly
 when available PowerShell access. The second output is C# code
 for PowerShell based loader code that will be used when powershell.exe
 is blocked. You can compile and run it, after that loader runs
 the PowerShell  based loader code using System.Management.Automation.dll.
 This module also has the ability to process patched stages.''')
        print("\n \033[1m\033[94m[*]\033[0m Module Options\033[0m")
        optionsValues = [
            ["Parameter", "Required", "Value", "Description"],
            ["PROTO", "Yes", mppProto, "Listener protocol. Accepted: http or https"],
            ["LHOST", "Yes", mppLhost, "The local listener hostname or IP address"],
            ["LPORT", "Yes", mppLport, "The local listener port."],
            ["ARCH", "Yes", mppArch, "Architecture of target system. Accepted: x86 or x64"],
            ["SSIZE", "No", mppSsize, "If you patched Metasploit insert your patch size"]
        ]
        optTable = AsciiTable(optionsValues)
        optTable.outer_border = False
        optTable.inner_column_border = False
        optTable.justify_columns[1] = "center"
        print("\n" + optTable.table + "\n") 
Example #27
Source File: spookflare.py    From SpookFlare with Apache License 2.0 5 votes vote down vote up
def do_list(self, line):
        optionsValues = [
            ["ID", "Payload", "Description"],
            ["1", "meterpreter/binary", ".EXE Meterpreter Reverse HTTP and HTTPS loader"],
            ["2", "meterpreter/powershell", "PowerShell based Meterpreter Reverse HTTP and HTTPS loader"],
            ["3", "javascript/hta", ".HTA loader with .HTML extension for specific command"],
            ["4", "vba/macro", "Office Macro loader for specific command"]
        ]
        optTable = AsciiTable(optionsValues)
        optTable.outer_border = False
        optTable.inner_column_border = True
        print("\n" + optTable.table + "\n") 
Example #28
Source File: ui.py    From CumulusCI with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def ascii_table(self):
        """Fallback for dumb terminals."""
        self.plain = AsciiTable(self._table.table_data, self._title)
        self.plain.inner_column_border = False
        self.plain.inner_row_border = False
        return self.plain.table 
Example #29
Source File: ui.py    From CumulusCI with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def echo(self, plain=False):
        """Print this table's data using click.echo().

        Automatically falls back to AsciiTable if there's an encoding error.
        """
        if plain or os.environ.get("TERM") == "dumb":
            table = self.ascii_table()
        else:
            table = str(self)
        click.echo(table) 
Example #30
Source File: helper.py    From rssant with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def format_table(rows, *, header=None, border=True):
    """
    >>> assert format_table([('a', 'b', 'c'), ('d', 'e', 'f')])
    """
    table_data = []
    if header:
        table_data.append(list(header))
    elif rows:
        table_data.append([f'#{i}' for i in range(len(rows[0]))])
    table_data.extend(rows)
    table = AsciiTable(table_data)
    if not border:
        table.inner_column_border = False
        table.outer_border = False
    return table.table