def main(): global channel done = False load_channel(chandefault) while not done: print("\n\tBinary Ninja Version Switcher") print("\t\tCurrent Channel:\t%s" % channel.name) print("\t\tCurrent Version:\t%s" % core_version()) print("\t\tAuto-Updates On:\t%s\n" % are_auto_updates_enabled()) for index, version in enumerate(versions): date = datetime.datetime.fromtimestamp(version.time).strftime('%c') print("\t%d)\t%s (%s)" % (index + 1, version.version, date)) print("\t%d)\t%s" % (len(versions) + 1, "Switch Channel")) print("\t%d)\t%s" % (len(versions) + 2, "Toggle Auto Updates")) print("\t%d)\t%s" % (len(versions) + 3, "Exit")) selection = input('Choice: ') if selection.isdigit(): selection = int(selection) else: selection = 0 if (selection <= 0 or selection > len(versions) + 3): print("%d is an invalid choice.\n\n" % selection) else: if (selection == len(versions) + 3): done = True elif (selection == len(versions) + 2): toggle_updates() elif (selection == len(versions) + 1): list_channels() else: select(versions[selection - 1])
def __init__(self, server, bv, *args, **kwargs): self.server = server self.view = bv self.base = bv.entry_point & ~(PAGE_SIZE - 1) self._version = ("Binary Ninja", core_version()) self.old_bps = set() return
def __init__(self, server, bv, *args, **kwargs): self.server = server self.view = bv self.base = bv.entry_point & ~(PAGE_SIZE - 1) self._version = ("Binary Ninja", core_version()) self.__old_bps = set() self.__breakpoints = set() tag_type = bv.tag_types[ "Breakpoints"] if "Breakpoints" in bv.tag_types else Tag self.__bp_tag = bv.create_tag(tag_type, "GEF Breakpoint", True) self.__current_instruction = 0 return
def select(version): done = False date = datetime.datetime.fromtimestamp(version.time).strftime('%c') while not done: print("Version:\t%s" % version.version) print("Updated:\t%s" % date) print("Notes:\n\n-----\n%s" % version.notes) print("-----") print("\t1)\tSwitch to version") print("\t2)\tMain Menu") selection = input('Choice: ') if selection.isdigit(): selection = int(selection) else: selection = 0 if (selection == 2): done = True elif (selection == 1): if (version.version == channel.latest_version.version): print("Requesting update to latest version.") else: print("Requesting update to prior version.") if are_auto_updates_enabled(): print("Disabling automatic updates.") set_auto_updates_enabled(False) if (version.version == core_version()): print("Already running %s" % version.version) else: print("version.version %s" % version.version) print("core_version %s" % core_version()) print("Downloading...") print(version.update()) print("Installing...") if is_update_installation_pending: #note that the GUI will be launched after update but should still do the upgrade headless install_pending_update() # forward updating won't work without reloading sys.exit() else: print("Invalid selection")
def _init_version(self): version_string = binaryninja.core_version() # retrieve Binja's version # if "-" in version_string: # dev disassembler_version = version_string.split("-", 1)[0] else: # commercial, personal disassembler_version = version_string.split(" ", 1)[0] major, minor, patch = map(int, disassembler_version.split(".")) # save the version number components for later use self._version_major = major self._version_minor = minor self._version_patch = patch
def validate_path(path): try: os.stat(path) except OSError: return False old_path = sys.path sys.path.append(path) try: from binaryninja import core_version print("Found Binary Ninja core version: {}".format(core_version())) except ImportError: sys.path = old_path return False return True
import binaryninja # guard against namespace package trap if not sys.modules['binaryninja'].__file__: raise Exception except Exception: standalone = True # warn if minimum version not met try: if standalone: raise Exception('no version check in standalone mode') from binaryninja import core_version, log_error (major, minor, buildid) = re.match(r'^(\d+)\.(\d+)\.?(\d+)?', core_version()).groups() major = int(major) minor = int(minor) buildid = int(buildid) if buildid is not None else 0xffffffff import json fpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'plugin.json') with open(fpath) as fp: data = json.load(fp) min_version = data['minimumbinaryninjaversion'] # git builds end with ' development' if not (core_version().endswith('development') or core_version().endswith('test')): if buildid < min_version:
settings.set_option(DisassemblyOption.ShowVariablesAtTopOfGraph) settings.set_option(DisassemblyOption.ShowVariableTypesWhenAssigned) settings.set_option(DisassemblyOption.ShowCallParameterNames) settings.set_option(DisassemblyOption.ShowRegisterHighlight) settings.set_option(DisassemblyOption.ShowFunctionAddress) settings.set_option(DisassemblyOption.ShowFunctionHeader) settings.set_option(DisassemblyOption.GroupLinearDisassemblyFunctions) settings.set_option(DisassemblyOption.HighLevelILLinearDisassembly) settings.set_option(DisassemblyOption.WaitForIL) settings.set_option(DisassemblyOption.IndentHLILBody) settings.set_option(DisassemblyOption.ShowFlagUsage) settings.set_option(DisassemblyOption.ShowStackPointer) print_divider('setup') print('python binaryninja module path: ' + binaryninja.__file__) print('core_version(): ' + binaryninja.core_version()) print('core_build_id(): %d (0x%X)' % (binaryninja.core_build_id(), binaryninja.core_build_id())) print_divider('architecture') print('registers:') for (name, reginfo) in bv.arch.regs.items(): print('name:%s index:%d offset:%d size:%d full_width_reg:%s' % \ (name, reginfo.index, reginfo.offset, reginfo.size, reginfo.full_width_reg)) print_divider('disassembly') obj = lineardisassembly.LinearViewObject.disassembly(bv, settings) cursor = lineardisassembly.LinearViewCursor(obj) print_cursor(cursor) # print_divider('lifted il')
from PySide2.QtGui import QPalette, QFontMetricsF from PySide2.QtWidgets import QApplication, QHBoxLayout, QVBoxLayout, QWidget, QStyle, QSplitter, QLabel import re import threading import binaryninjaui from binaryninja import BinaryView, PythonScriptingInstance, InstructionTextToken, InstructionTextTokenType, DisassemblyTextLine, LinearDisassemblyLine, LinearDisassemblyLineType, HighlightStandardColor, core_version from binaryninja.enums import InstructionTextTokenType from binaryninjaui import View, ViewType, UIAction, UIActionHandler, LinearView, DisassemblyContainer, ViewFrame, DockHandler, TokenizedTextView, HistoryEntry from . import widget, ControlsWidget from .. import binjaplug (major, minor, buildid) = re.match(r'^(\d+)\.(\d+)\.?(\d+)?', core_version()).groups() major = int(major) minor = int(minor) buildid = int(buildid) if buildid is not None else 0xffffffff class DebugView(QWidget, View): class DebugViewHistoryEntry(HistoryEntry): def __init__(self, memory_addr, address, is_raw): HistoryEntry.__init__(self) self.memory_addr = memory_addr self.address = address self.is_raw = is_raw def __repr__(self):
# source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'Binary Ninja API' copyright = u'2015-2019, Vector 35 Inc' author = u'Vector 35 Inc' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = u'.'.join(unicode(binaryninja.core_version()).split('.')[0:2]) release = unicode(binaryninja.core_version()) language = 'en' exclude_patterns = [] # add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). # add_module_names = False # The name of the Pygments (syntax highlighting) style to use.
# This plugin supports scripting both in the ui and in headless plugins # Start scripts with the following: # import debugger # dbg = debugger.get(bv) # warn if minimum version not met import binaryninja import sys import re min_version = 2085 (incrementing, development) = re.search(r"^\d+.\d+.(\d+).*( development)?", binaryninja.core_version()).groups() # git builds end with ' development' if not development: if int(incrementing) < min_version: message = "Debugger relies on features and fixes present in Binary Ninja >= {}. Errors may follow, please update.".format( min_version) if binaryninja.core_ui_enabled(): binaryninja.interaction.show_message_box( "Debugger Version Check Failed", message) else: print(message, file=sys.stderr) from . import binjaplug """ Retrieve the debugger state instance for a given BinaryView """
init_ref(ref, ref_from, cur_addr, 3) logging.info("[data Ref]: 0x%x -> 0x%x" % (ref_from , cur_addr)) pbout = open(output, 'wb') pbout.write(refInf.SerializeToString()) pbout.close() if __name__ == "__main__": parser = optparse.OptionParser() parser.add_option("-o", "--output", dest = "output", action= "store", type = "string", \ help = "output of the protobuf file", default = "/tmp/angr_blocks.pb2") parser.add_option("-b", "--binary", dest = "binary", action = "store", type = "string", \ help = "binary file", default = None) parser.add_option("-s", "--ss", dest = "ss", action = "store", type = "string", \ help = "dummy option. (do not use)", default = None) (options, args) = parser.parse_args() if options.binary == None: binja.log_info("please input the binary file") exit(-1) bv = binja.BinaryViewType.get_view_of_file(options.binary) #binja.log_to_stdout(binja.LogLevel.DebugLog) binja.log_to_stdout(binja.LogLevel.ErrorLog) #binja.log_info("----------------- %s ------------" % options.binary) binja.log_info("START: 0x%x" % bv.start) binja.log_info("ENTRY: 0x%x" % bv.entry_point) binja.log_info("ARCH: %s" % bv.arch.name) logging.info("version: %s" % core_version()) binja.log_info("\n--------------- Function List -----------") #bv.update_analysis_and_wait() dumpRefs(bv, options.output)
# source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'Binary Ninja Python API' copyright = u'2015-2021, Vector 35 Inc' author = u'Vector 35 Inc' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = u'.'.join(str(binaryninja.core_version()).split('.')[0:2]) release = str(binaryninja.core_version()) language = 'en' exclude_patterns = [] add_function_parentheses = False # If true, the current module name will be prepended to all description # unit titles (such as .. function::). # add_module_names = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'trac'
from PySide2.QtCore import Qt, QAbstractItemModel, QModelIndex, QSize, QTimer from PySide2.QtGui import QPalette, QFontMetricsF from PySide2.QtWidgets import QApplication, QHBoxLayout, QVBoxLayout, QWidget, QStyle, QSplitter, QLabel import re import threading import binaryninjaui from binaryninja import BinaryView, PythonScriptingInstance, InstructionTextToken, InstructionTextTokenType, DisassemblyTextLine, LinearDisassemblyLine, LinearDisassemblyLineType, HighlightStandardColor, core_version from binaryninja.enums import InstructionTextTokenType from binaryninjaui import View, ViewType, UIAction, UIActionHandler, LinearView, DisassemblyContainer, ViewFrame, DockHandler, TokenizedTextView, HistoryEntry from . import widget, ControlsWidget from .. import binjaplug (major, minor, buildid) = re.match(r'^(\d+)\.(\d+)\.?(\d+)?', core_version()).groups() major = int(major) minor = int(minor) buildid = int(buildid) if buildid is not None else 0xffffffff class DebugView(QWidget, View): class DebugViewHistoryEntry(HistoryEntry): def __init__(self, memory_addr, address, is_raw): HistoryEntry.__init__(self) self.memory_addr = memory_addr self.address = address self.is_raw = is_raw def __repr__(self): if self.is_raw:
# source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'Binary Ninja API' copyright = u'2015-2019, Vector 35 Inc' author = u'Vector 35 Inc' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = u'.'.join(unicode(binaryninja.core_version()).split('.')[0:2]) release = unicode(binaryninja.core_version()) language = 'en' exclude_patterns = [] # add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). # add_module_names = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx'