コード例 #1
0
    def execute(self, api: Api):

        want_to_continue = api.ask_user(
            "Warning",
            "This plugin may replace some of your comments, continue?")
        if not want_to_continue:
            return

        trace_data = api.get_trace_data()
        trace = api.get_visible_trace()

        for i, t in enumerate(trace):
            if 'mem' in t and t['mem']:
                comment = ""
                for mem in t['mem']:
                    addr = hex(mem['addr'])
                    value = mem['value']
                    if mem['access'] == "READ":
                        comment += f"[{ addr }] -> { hex(value) } "
                    elif mem['access'] == "WRITE":
                        comment += f"[{ addr }] <- { hex(value) } "
                    if 0x20 <= value <= 0x7e:
                        comment += f"'{ chr(value) }' "

                # Add comment to full trace
                row = t["id"]
                trace_data.trace[row]['comment'] = comment

                # Add comment to visible trace too because it could be filtered_trace
                trace[i]['comment'] = comment

        api.update_trace_table()
コード例 #2
0
    def execute(self, api: Api):

        trace = api.get_visible_trace()
        if not trace:
            return

        api.print('')

        trace_data = api.get_trace_data()
        ip_name = trace_data.get_instruction_pointer_name()
        if ip_name not in trace_data.regs:
            api.print('Error. Unknown instruction pointer name.')
            return
        ip_index = trace_data.regs[ip_name]
        counts = {}
        for t in trace:
            addr = t['regs'][ip_index]
            if addr in counts:
                counts[addr] += 1
            else:
                counts[addr] = 1

        api.print('%d unique addresses executed.' % len(counts))
        api.print('Top 30 executed addresses:')

        counts = sorted(counts.items(), key=itemgetter(1), reverse=True)
        for address, count in counts[:30]:
            api.print('%s  %d ' % (hex(address), count))
コード例 #3
0
    def execute(self, api: Api):

        trace_data = api.get_trace_data()
        trace = api.get_selected_trace()

        if not trace:
            print('PluginPrintRows error: Nothing selected.')
            return

        api.print('')

        row_id_digits = len(str(trace[-1]['id']))
        for t in trace:
            ip = hex(trace_data.get_instruction_pointer(t['id']))
            api.print('{:<{}} '.format(t['id'], row_id_digits) + ' %s ' % ip +
                      ' {:<42}'.format(t['disasm']) + '; %s' % t['comment'])
コード例 #4
0
    def execute(self, api: Api):

        trace_data = api.get_trace_data()
        trace = api.get_selected_trace()

        if not trace:
            print("PluginPrintRows error: Nothing selected.")
            return

        api.print("")

        row_id_digits = len(str(trace[-1]["id"]))
        for t in trace:
            ip = hex(trace_data.get_instruction_pointer(t["id"]))
            api.print("{:<{}} ".format(t["id"], row_id_digits) + " %s " % ip +
                      " {:<42}".format(t["disasm"]) +
                      "; %s" % t.get("comment", ""))