当前位置: 首页>>代码示例>>Python>>正文


Python binaryninja.BinaryView方法代码示例

本文整理汇总了Python中binaryninja.BinaryView方法的典型用法代码示例。如果您正苦于以下问题:Python binaryninja.BinaryView方法的具体用法?Python binaryninja.BinaryView怎么用?Python binaryninja.BinaryView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在binaryninja的用法示例。


在下文中一共展示了binaryninja.BinaryView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: is_section_external

# 需要导入模块: import binaryninja [as 别名]
# 或者: from binaryninja import BinaryView [as 别名]
def is_section_external(bv, sect):
  """Returns `True` if the given section contains only external references

  Args:
    bv (binja.BinaryView)
    sect (binja.binaryview.Section)
  """
  if sect.start in _EXT_SECTIONS:
    return True

  if sect.start in _INT_SECTIONS:
    return False

  if is_ELF(bv):
    if re.search(r'\.(got|plt)', sect.name):
      _EXT_SECTIONS.add(sect.start)
      return True

  if is_PE(bv):
    if '.idata' in sect.name:
      _EXT_SECTIONS.add(sect.start)
      return True

  _INT_SECTIONS.add(sect.start)
  return False 
开发者ID:lifting-bits,项目名称:mcsema,代码行数:27,代码来源:util.py

示例2: recover_ext_var

# 需要导入模块: import binaryninja [as 别名]
# 或者: from binaryninja import BinaryView [as 别名]
def recover_ext_var(bv, pb_mod, sym):
  """ Recover external variable information

  Args:
    bv (binja.BinaryView)
    pb_mod (CFG_pb2.Module)
    sym (binja.types.Symbol)
  """
  if sym.name in EXT_DATA_MAP:
    DEBUG("Recovering external variable {} at {:x}".format(sym.name, sym.address))

    pb_extvar = pb_mod.external_vars.add()
    pb_extvar.name = sym.name
    pb_extvar.ea = sym.address
    pb_extvar.size = EXT_DATA_MAP[sym.name]
    pb_extvar.is_weak = False  # TODO: figure out how to decide this
    pb_extvar.is_thread_local = util.is_tls_section(bv, sym.address)
  else:
    ERROR("Unknown external variable {} at {:x}".format(sym.name, sym.address)) 
开发者ID:lifting-bits,项目名称:mcsema,代码行数:21,代码来源:cfg.py

示例3: fix_tail_call_targets

# 需要导入模块: import binaryninja [as 别名]
# 或者: from binaryninja import BinaryView [as 别名]
def fix_tail_call_targets(bv, func):
  """
  Binja will "inline" tail calls into the current function, resulting in the
  same blocks appearing in multiple functions. This detects if this happened
  and defines a function at the first inlined block so nothing is duplicated

  Args:
    bv (binja.BinaryView)
    func (binja.Function)
  """
  for block in func.basic_blocks:
    # This will return a list of all basic blocks starting at the same address
    # The same block appearing in different functions (after inlining)
    # will appear as multiple `BasicBlock`s
    all_blocks = bv.get_basic_blocks_at(block.start)

    # There should only be a single block found
    if len(all_blocks) > 1:
      log.debug('Block 0x%x exists in multiple functions, defining a new function here', block.start)

      # Define a function here and reanalyze
      # All blocks contained in this new function will not be picked up
      # in the remainder of this loop after analysis
      bv.add_function(block.start)
      bv.update_analysis_and_wait() 
开发者ID:lifting-bits,项目名称:mcsema,代码行数:27,代码来源:cfg.py

示例4: _define_selectors

# 需要导入模块: import binaryninja [as 别名]
# 或者: from binaryninja import BinaryView [as 别名]
def _define_selectors(view: BinaryView):
    __objc_selrefs = view.sections.get('__objc_selrefs')

    if __objc_selrefs is None:
        raise KeyError('This binary has no __objc_selrefs section')

    SEL = view.get_type_by_name('SEL')
    if SEL is None:
        raise TypeError('The SEL type is not defined!')

    for addr in range(__objc_selrefs.start, __objc_selrefs.end, SEL.width):
        view.define_user_data_var(addr, SEL)
        selector = int.from_bytes(view.read(addr, SEL.width), "little")
        if selector != 0:
            name = view.get_ascii_string_at(selector, 3)
            if name is not None:
                view.define_user_data_var(name.start, Type.array(Type.char(), name.length+1)) 
开发者ID:trailofbits,项目名称:ObjCGraphView,代码行数:19,代码来源:selectors.py

示例5: __init__

# 需要导入模块: import binaryninja [as 别名]
# 或者: from binaryninja import BinaryView [as 别名]
def __init__(self, data):
        binaryninja.BinaryView.__init__(self, file_metadata=data.file, parent_view=data)
        self.raw = data 
开发者ID:fluxchief,项目名称:binaryninja_avr,代码行数:5,代码来源:__init__.py

示例6: __init__

# 需要导入模块: import binaryninja [as 别名]
# 或者: from binaryninja import BinaryView [as 别名]
def __init__(self, parent, name, data):
		if not type(data) == BinaryView:
			raise Exception('expected widget data to be a BinaryView')

		self.bv = data

		QWidget.__init__(self, parent)
		DockContextHandler.__init__(self, self, name)
		self.actionHandler = UIActionHandler()
		self.actionHandler.setupActionHandler(self)

		self.table = QTableView(self)
		self.model = DebugThreadsListModel(self.table)
		self.table.setModel(self.model)
		self.table.clicked.connect(self.threadRowClicked)

		self.item_delegate = DebugThreadsItemDelegate(self)
		self.table.setItemDelegate(self.item_delegate)

		# self.table.setSortingEnabled(True)
		self.table.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
		self.table.setSelectionMode(QAbstractItemView.ExtendedSelection)

		self.table.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
		self.table.verticalHeader().setVisible(False)

		self.table.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel)
		self.table.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)

		self.table.resizeColumnsToContents()
		self.table.resizeRowsToContents()

		for i in range(len(self.model.columns)):
			self.table.setColumnWidth(i, self.item_delegate.sizeHint(self.table.viewOptions(), self.model.index(-1, i, QModelIndex())).width())
		self.table.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)

		layout = QVBoxLayout()
		layout.setContentsMargins(0, 0, 0, 0)
		layout.setSpacing(0)
		layout.addWidget(self.table)
		self.setLayout(layout) 
开发者ID:Vector35,项目名称:debugger,代码行数:43,代码来源:ThreadsWidget.py

示例7: __init__

# 需要导入模块: import binaryninja [as 别名]
# 或者: from binaryninja import BinaryView [as 别名]
def __init__(self, parent, name, data):
		if not type(data) == BinaryView:
			raise Exception('expected widget data to be a BinaryView')

		self.bv = data

		QWidget.__init__(self, parent)
		DockContextHandler.__init__(self, self, name)
		self.actionHandler = UIActionHandler()
		self.actionHandler.setupActionHandler(self)

		self.table = QTableView(self)
		self.model = DebugStackModel(self.table, data)
		self.table.setModel(self.model)

		self.item_delegate = DebugStackItemDelegate(self)
		self.table.setItemDelegate(self.item_delegate)

		# self.table.setSortingEnabled(True)
		self.table.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
		self.table.setSelectionMode(QAbstractItemView.ExtendedSelection)

		self.table.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
		self.table.verticalHeader().setVisible(False)

		self.table.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel)
		self.table.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)

		self.table.resizeColumnsToContents()
		self.table.resizeRowsToContents()

		for i in range(len(self.model.columns)):
			self.table.setColumnWidth(i, self.item_delegate.sizeHint(self.table.viewOptions(), self.model.index(-1, i, QModelIndex())).width())

		layout = QVBoxLayout()
		layout.setContentsMargins(0, 0, 0, 0)
		layout.setSpacing(0)
		layout.addWidget(self.table)
		self.setLayout(layout) 
开发者ID:Vector35,项目名称:debugger,代码行数:41,代码来源:StackWidget.py

示例8: __init__

# 需要导入模块: import binaryninja [as 别名]
# 或者: from binaryninja import BinaryView [as 别名]
def __init__(self, parent, name, data):
		if not type(data) == BinaryView:
			raise Exception('expected widget data to be a BinaryView')

		self.bv = data

		QWidget.__init__(self, parent)
		DockContextHandler.__init__(self, self, name)
		self.actionHandler = UIActionHandler()
		self.actionHandler.setupActionHandler(self)

		self.table = QTableView(self)
		self.model = DebugBreakpointsListModel(self.table, data)
		self.table.setModel(self.model)

		self.item_delegate = DebugBreakpointsItemDelegate(self)
		self.table.setItemDelegate(self.item_delegate)

		# self.table.setSortingEnabled(True)
		self.table.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
		self.table.setSelectionMode(QAbstractItemView.ExtendedSelection)

		self.table.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
		self.table.verticalHeader().setVisible(False)

		self.table.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel)
		self.table.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)

		self.table.resizeColumnsToContents()
		self.table.resizeRowsToContents()

		for i in range(len(self.model.columns)):
			self.table.setColumnWidth(i, self.item_delegate.sizeHint(self.table.viewOptions(), self.model.index(-1, i, QModelIndex())).width())
		self.table.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)

		layout = QVBoxLayout()
		layout.setContentsMargins(0, 0, 0, 0)
		layout.setSpacing(0)
		layout.addWidget(self.table)
		self.setLayout(layout) 
开发者ID:Vector35,项目名称:debugger,代码行数:42,代码来源:BreakpointsWidget.py

示例9: __init__

# 需要导入模块: import binaryninja [as 别名]
# 或者: from binaryninja import BinaryView [as 别名]
def __init__(self, parent, name, data):
		if not type(data) == BinaryView:
			raise Exception('expected widget data to be a BinaryView')

		self.bv = data

		QWidget.__init__(self, parent)
		DockContextHandler.__init__(self, self, name)
		self.actionHandler = UIActionHandler()
		self.actionHandler.setupActionHandler(self)

		self.table = QTableView(self)
		self.model = DebugRegistersListModel(self.table, data)
		self.table.setModel(self.model)

		self.item_delegate = DebugRegistersItemDelegate(self)
		self.table.setItemDelegate(self.item_delegate)

		# self.table.setSortingEnabled(True)
		self.table.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
		self.table.setSelectionMode(QAbstractItemView.ExtendedSelection)

		self.table.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
		self.table.verticalHeader().setVisible(False)

		self.table.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel)
		self.table.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)

		self.table.resizeColumnsToContents()
		self.table.resizeRowsToContents()

		for i in range(len(self.model.columns)):
			self.table.setColumnWidth(i, self.item_delegate.sizeHint(self.table.viewOptions(), self.model.index(-1, i, QModelIndex())).width())

		layout = QVBoxLayout()
		layout.setContentsMargins(0, 0, 0, 0)
		layout.setSpacing(0)
		layout.addWidget(self.table)
		self.setLayout(layout) 
开发者ID:Vector35,项目名称:debugger,代码行数:41,代码来源:RegistersWidget.py

示例10: read_dword

# 需要导入模块: import binaryninja [as 别名]
# 或者: from binaryninja import BinaryView [as 别名]
def read_dword(bv, addr):
  # type: (binja.BinaryView, int) -> int
  # Pad the data if fewer than 4 bytes are read
  endianness = ENDIAN_TO_STRUCT[bv.endianness]
  data = bv.read(addr, 4)
  padded_data = '{{:\x00{}4s}}'.format(endianness).format(data)
  fmt = '{}L'.format(endianness)
  return struct.unpack(fmt, padded_data)[0] 
开发者ID:lifting-bits,项目名称:mcsema,代码行数:10,代码来源:util.py

示例11: read_qword

# 需要导入模块: import binaryninja [as 别名]
# 或者: from binaryninja import BinaryView [as 别名]
def read_qword(bv, addr):
  # type: (binja.BinaryView, int) -> int
  # Pad the data if fewer than 8 bytes are read
  endianness = ENDIAN_TO_STRUCT[bv.endianness]
  data = bv.read(addr, 8)
  padded_data = '{{:\x00{}8s}}'.format(endianness).format(data)
  fmt = '{}Q'.format(endianness)
  return struct.unpack(fmt, padded_data)[0] 
开发者ID:lifting-bits,项目名称:mcsema,代码行数:10,代码来源:util.py

示例12: find_symbol_name

# 需要导入模块: import binaryninja [as 别名]
# 或者: from binaryninja import BinaryView [as 别名]
def find_symbol_name(bv, addr):
  """Attempt to find a symbol for a given address

  Args:
    bv (binja.BinaryView)
    addr (int): Address the symbol should point to

  Returns:
    (str): Symbol name if found, empty string otherwise

  """
  sym = bv.get_symbol_at(addr)
  if sym is not None:
    return sym.name
  return '' 
开发者ID:lifting-bits,项目名称:mcsema,代码行数:17,代码来源:util.py

示例13: get_func_containing

# 需要导入模块: import binaryninja [as 别名]
# 或者: from binaryninja import BinaryView [as 别名]
def get_func_containing(bv, addr):
  """ Finds the function, if any, containing the given address
  Args:
    bv (binja.BinaryView)
    addr (int)

  Returns:
    binja.Function
  """
  funcs = bv.get_functions_containing(addr)
  return funcs[0] if funcs is not None else None 
开发者ID:lifting-bits,项目名称:mcsema,代码行数:13,代码来源:util.py

示例14: recover_section_vars

# 需要导入模块: import binaryninja [as 别名]
# 或者: from binaryninja import BinaryView [as 别名]
def recover_section_vars(bv, pb_seg, sect_start, sect_end):
  """ Gather any symbols that point to data in this section

  Args:x
    bv (binja.BinaryView)
    pb_seg (CFG_pb2.Segment)
    sect_start (int)
    sect_end (int)
  """

  DEBUG("Recovering variables in [{:x}, {:x}) of section {}".format(
      sect_start, sect_end, pb_seg.name))
  DEBUG_PUSH()
  for sym in bv.get_symbols():
    # Ignore functions and externals
    if sym.type in [SymbolType.FunctionSymbol,
            SymbolType.ImportedFunctionSymbol,
            SymbolType.ImportedDataSymbol,
            SymbolType.ImportAddressSymbol]:
      continue

    if sect_start <= sym.address < sect_end:
      DEBUG("Adding variable {} at {:x}".format(sym.name, sym.address))
      pb_segvar = pb_seg.vars.add()
      pb_segvar.ea = sym.address
      pb_segvar.name = sym.name

  DEBUG_POP() 
开发者ID:lifting-bits,项目名称:mcsema,代码行数:30,代码来源:cfg.py

示例15: read_inst_bytes

# 需要导入模块: import binaryninja [as 别名]
# 或者: from binaryninja import BinaryView [as 别名]
def read_inst_bytes(bv, il):
  """ Get the opcode bytes for an instruction
  Args:
    bv (binja.BinaryView)
    il (binja.LowLevelILInstruction)
  Returns:
    str
  """
  inst_len = bv.get_instruction_length(il.address)
  return bv.read(il.address, inst_len) 
开发者ID:lifting-bits,项目名称:mcsema,代码行数:12,代码来源:cfg.py


注:本文中的binaryninja.BinaryView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。