Exemplo n.º 1
0
def main(binary):
    file_path = data_dir + binary + json_ext
    if os.path.isfile(file_path):
        print(info.safe_substitute(text="Supplied binary: " + binary))
        print(info.safe_substitute(text="Please wait, loading data ... "))
        with open(file_path) as source:
            data = source.read()

        json_data = json.loads(data)
        if 'description' in json_data:
            print('\n' + description.safe_substitute(
                description=json_data['description']))

        for vector in json_data['functions']:
            print(title.safe_substitute(title=str(vector).upper()))
            index = 0
            for code in json_data['functions'][vector]:
                index = index + 1
                if 'description' in code:
                    print(
                        description.safe_substitute(
                            description=code['description']) + '\n')
                print(
                    highlight(
                        code['code'], lexers.BashLexer(),
                        formatters.TerminalTrueColorFormatter(
                            style='igor')).strip())
                if index != len(json_data['functions'][vector]):
                    print(divider)

        print('\n' + info.safe_substitute(text="Goodbye, friend."))
    else:
        print(
            fail.safe_substitute(text="Sorry, couldn't find anything for " +
                                 binary))
Exemplo n.º 2
0
 def shell(self):
     IPython.embed(header=highlight(
         SHELL_USAGE, lexers.PythonLexer(),
         formatters.TerminalTrueColorFormatter(style='native')),
                   user_ns={
                       'client': self,
                   })
Exemplo n.º 3
0
 def shell(self):
     IPython.embed(
         header=highlight(SHELL_USAGE, lexers.PythonLexer(), formatters.TerminalTrueColorFormatter(style='native')),
         user_ns={
             'developer': self,
             'MessageAux': MessageAux,
         })
Exemplo n.º 4
0
def pcap(lockdown, out, count, process, nocolor):
    """ sniff device traffic """
    service = PcapdService(lockdown=lockdown)
    packets_generator = service.watch(packets_count=count, process=process)
    if out is not None:
        service.write_to_pcap(out, packets_generator)
        return

    formatter = formatters.TerminalTrueColorFormatter(style='native')

    for packet in packets_generator:
        date = datetime.fromtimestamp(packet.seconds + (packet.microseconds / 1000000))
        data = (
            f'{date}: '
            f'Process {packet.comm} ({packet.pid}), '
            f'Interface: {packet.interface_name} ({packet.interface_type.name}), '
            f'Family: {packet.protocol_family.name}'
        )
        if nocolor:
            print(data)
        else:
            print(highlight(data, lexers.HspecLexer(), formatter), end='')
        hex_dump = hexdump.hexdump(packet.data, result='return')
        if nocolor:
            print(hex_dump, end='\n\n')
        else:
            print(highlight(hex_dump, lexers.HexdumpLexer(), formatter))
Exemplo n.º 5
0
def colorize_json(data, style='algol_nu'):
    """Colorize json output using ``pygments``.
    """
    formatted_json = json.dumps(data, sort_keys=True, indent=4)
    return highlight(
        formatted_json,
        lexers.JsonLexer(),
        # likeable styles: algol_nu, tango, monokai
        formatters.TerminalTrueColorFormatter(style=style))
Exemplo n.º 6
0
    def __init__(self):
        self.use_terminal256formatter = False
        self.formatter = formatters.TerminalTrueColorFormatter(style="monokai")

        return