예제 #1
0
    def _paint_nodes(self, node_addresses):
        bv = disassembler[self.lctx].bv
        db_coverage = self.director.coverage
        db_metadata = self.director.metadata

        r, g, b, _ = self.palette.coverage_paint.getRgb()
        color = HighlightColor(red=r, green=g, blue=b)

        partial_nodes = set()
        for node_address in node_addresses:
            node_metadata = db_metadata.nodes.get(node_address, None)
            node_coverage = db_coverage.nodes.get(node_address, None)

            # read comment in ida_painter.py (self._paint_nodes)
            if not (node_coverage and node_metadata):
                self._msg_queue.put(self.MSG_ABORT)
                node_addresses = node_addresses[:node_addresses.
                                                index(node_address)]
                break

            # special case for nodes that are only partially executed...
            if node_coverage.instructions_executed != node_metadata.instruction_count:
                partial_nodes.add(node_address)
                self._partial_paint(bv,
                                    node_coverage.executed_instructions.keys(),
                                    color)
                continue

            for node in bv.get_basic_blocks_starting_at(node_address):
                node.highlight = color

        self._painted_nodes |= (set(node_addresses) - partial_nodes)
        self._action_complete.set()
예제 #2
0
def avoid_instr(bv, addr):
	# Highlight the instruction in red
	blocks = bv.get_basic_blocks_at(addr)
	for block in blocks:
		block.set_auto_highlight(HighlightColor(HighlightStandardColor.RedHighlightColor, alpha = 128))
		block.function.set_auto_instr_highlight(addr, HighlightStandardColor.RedHighlightColor)

	# Add the instruction to the list associated with the current view
	bv.session_data.angr_avoid.add(addr)
예제 #3
0
 def _paint_nodes(self, nodes_coverage):
     bv = disassembler.bv
     b, g, r = to_rgb(self.palette.coverage_paint)
     color = HighlightColor(red=r, green=g, blue=b)
     for node_coverage in nodes_coverage:
         node_metadata = node_coverage.database._metadata.nodes[node_coverage.address]
         for node in bv.get_basic_blocks_starting_at(node_metadata.address):
             node.highlight = color
         self._painted_nodes.add(node_metadata.address)
     self._action_complete.set()
예제 #4
0
파일: view.py 프로젝트: psifertex/wakare-ui
    def _bb_highlight(self, highlight):
        def delete_hitcount_str(input_str):
            if "(hitcount: " not in input_str:
                return input_str

            chk = input_str[input_str.find("(hitcount: "):]

            if ")\n" not in input_str:
                return input_str

            chk = chk[:input_str.find(")\n") + 2]

            return input_str.replace(chk, "")

        # (0, 255, 106)
        colorHighlight = HighlightColor(red=0, green=255, blue=106)

        for bbaddr, bbhitcount in self.hitcounts:
            bbs = self.bv.get_basic_blocks_at(bbaddr)

            if not bbs:
                print("Could not find basic block at address: 0x{:x}".format(
                    bbaddr))
                continue

            bb = bbs[0]
            fn = bb.function

            if not fn:
                print(
                    "Could not find function containing block at address: 0x{:x}"
                    .format(bbaddr))
                continue

            cur_comment = delete_hitcount_str(fn.get_comment_at(bbaddr))

            if highlight:
                bb.set_user_highlight(colorHighlight)
                fn.set_comment_at(
                    bbaddr,
                    "(hitcount: {})\n".format(bbhitcount) + cur_comment)
            else:
                bb.set_user_highlight(HighlightStandardColor.NoHighlightColor)
                fn.set_comment_at(bbaddr, cur_comment)
예제 #5
0
from logging.handlers import RotatingFileHandler
from collections import namedtuple

from binaryninja.highlight import HighlightColor
from binaryninja.enums import HighlightStandardColor

try:
    from ConfigParser import SafeConfigParser
except ImportError:
    from configparser import ConfigParser as SafeConfigParser

# networking settings
HOST = 'localhost'
PORT = 9100

CB_TRACE_COLOR = HighlightColor(HighlightStandardColor.GreenHighlightColor,
                                alpha=192)

# encoding settings (for data going in/out the plugin)
RS_ENCODING = 'utf-8'

# debugging settings
# enable/disable logging JSON received in the IDA output window
DEBUG_JSON = False

# global log level (console output)
LOG_LEVEL = logging.INFO

# log prefix to identify plugin
LOG_PREFIX = 'sync'

# enable/disable broker and dipatcher exception logging to file