コード例 #1
0
ファイル: plugin.py プロジェクト: mattz0rt/binaryninja-api
    def register_for_medium_level_il_instruction(cls,
                                                 name,
                                                 description,
                                                 action,
                                                 is_valid=None):
        """
		``register_for_medium_level_il_instruction`` Register a plugin to be called with a medium level IL instruction argument

		:param str name: name of the plugin
		:param str description: description of the plugin
		:param action: function to call with the ``BinaryView`` and a ``MediumLevelILInstruction`` as arguments
		:param is_valid: optional argument of a function passed a ``BinaryView`` to determine whether the plugin should be enabled for that view
		:rtype: None

		.. warning:: Calling ``register_for_medium_level_il_instruction`` with the same function name will replace the existing function but will leak the memory of the original plugin.
		"""
        startup._init_plugins()
        action_obj = ctypes.CFUNCTYPE(
            None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView),
            ctypes.POINTER(core.BNMediumLevelILFunction), ctypes.c_ulonglong)(
                lambda ctxt, view, func, instr: cls.
                _medium_level_il_instruction_action(view, func, instr, action))
        is_valid_obj = ctypes.CFUNCTYPE(
            ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView),
            ctypes.POINTER(core.BNMediumLevelILFunction),
            ctypes.c_ulonglong)(lambda ctxt, view, func, instr: cls.
                                _medium_level_il_instruction_is_valid(
                                    view, func, instr, is_valid))
        cls._registered_commands.append((action_obj, is_valid_obj))
        core.BNRegisterPluginCommandForMediumLevelILInstruction(
            name, description, action_obj, is_valid_obj, None)
コード例 #2
0
 def __getitem__(self, value):
     startup._init_plugins()
     provider = core.BNGetScriptingProviderByName(str(value))
     if provider is None:
         raise KeyError("'%s' is not a valid scripting provider" %
                        str(value))
     return ScriptingProvider(provider)
コード例 #3
0
	def __iter__(self):
		startup._init_plugins()
		count = ctypes.c_ulonglong()
		types = core.BNGetScriptingProviderList(count)
		try:
			for i in xrange(0, count.value):
				yield ScriptingProvider(types[i])
		finally:
			core.BNFreeScriptingProviderList(types)
コード例 #4
0
 def __iter__(self):
     startup._init_plugins()
     count = ctypes.c_ulonglong()
     commands = core.BNGetAllPluginCommands(count)
     try:
         for i in xrange(0, count.value):
             yield PluginCommand(commands[i])
     finally:
         core.BNFreePluginCommandList(commands)
コード例 #5
0
 def __iter__(self):
     startup._init_plugins()
     count = ctypes.c_ulonglong()
     types = core.BNGetScriptingProviderList(count)
     try:
         for i in xrange(0, count.value):
             yield ScriptingProvider(types[i])
     finally:
         core.BNFreeScriptingProviderList(types)
コード例 #6
0
 def list(self):
     startup._init_plugins()
     count = ctypes.c_ulonglong()
     commands = core.BNGetAllPluginCommands(count)
     result = []
     for i in xrange(0, count.value):
         result.append(PluginCommand(commands[i]))
     core.BNFreePluginCommandList(commands)
     return result
コード例 #7
0
ファイル: plugin.py プロジェクト: joshwatson/binaryninja-api
	def list(self):
		startup._init_plugins()
		count = ctypes.c_ulonglong()
		commands = core.BNGetAllPluginCommands(count)
		result = []
		for i in xrange(0, count.value):
			result.append(PluginCommand(commands[i]))
		core.BNFreePluginCommandList(commands)
		return result
コード例 #8
0
	def __iter__(self):
		startup._init_plugins()
		count = ctypes.c_ulonglong()
		platforms = core.BNGetPlatformList(count)
		try:
			for i in xrange(0, count.value):
				yield Platform(None, core.BNNewPlatformReference(platforms[i]))
		finally:
			core.BNFreePlatformList(platforms, count.value)
コード例 #9
0
	def list(self):
		startup._init_plugins()
		count = ctypes.c_ulonglong()
		platforms = core.BNGetPlatformList(count)
		result = []
		for i in xrange(0, count.value):
			result.append(Platform(None, core.BNNewPlatformReference(platforms[i])))
		core.BNFreePlatformList(platforms, count.value)
		return result
コード例 #10
0
 def list(self):
     startup._init_plugins()
     count = ctypes.c_ulonglong()
     xforms = core.BNGetTransformTypeList(count)
     result = []
     for i in xrange(0, count.value):
         result.append(Transform(xforms[i]))
     core.BNFreeTransformTypeList(xforms)
     return result
コード例 #11
0
 def os_list(self):
     startup._init_plugins()
     count = ctypes.c_ulonglong()
     platforms = core.BNGetPlatformOSList(count)
     result = []
     for i in xrange(0, count.value):
         result.append(str(platforms[i]))
     core.BNFreePlatformOSList(platforms, count.value)
     return result
コード例 #12
0
	def list(self):
		startup._init_plugins()
		count = ctypes.c_ulonglong()
		xforms = core.BNGetTransformTypeList(count)
		result = []
		for i in xrange(0, count.value):
			result.append(Transform(xforms[i]))
		core.BNFreeTransformTypeList(xforms)
		return result
コード例 #13
0
ファイル: plugin.py プロジェクト: joshwatson/binaryninja-api
	def __iter__(self):
		startup._init_plugins()
		count = ctypes.c_ulonglong()
		tasks = core.BNGetRunningBackgroundTasks(count)
		try:
			for i in xrange(0, count.value):
				yield BackgroundTask(core.BNNewBackgroundTaskReference(tasks[i]))
		finally:
			core.BNFreeBackgroundTaskList(tasks)
コード例 #14
0
ファイル: plugin.py プロジェクト: joshwatson/binaryninja-api
	def __iter__(self):
		startup._init_plugins()
		count = ctypes.c_ulonglong()
		commands = core.BNGetAllPluginCommands(count)
		try:
			for i in xrange(0, count.value):
				yield PluginCommand(commands[i])
		finally:
			core.BNFreePluginCommandList(commands)
コード例 #15
0
	def list(self):
		startup._init_plugins()
		count = ctypes.c_ulonglong()
		platforms = core.BNGetPlatformList(count)
		result = []
		for i in xrange(0, count.value):
			result.append(Platform(None, core.BNNewPlatformReference(platforms[i])))
		core.BNFreePlatformList(platforms, count.value)
		return result
コード例 #16
0
 def __iter__(self):
     startup._init_plugins()
     count = ctypes.c_ulonglong()
     xforms = core.BNGetTransformTypeList(count)
     try:
         for i in xrange(0, count.value):
             yield Transform(xforms[i])
     finally:
         core.BNFreeTransformTypeList(xforms)
コード例 #17
0
 def __iter__(self):
     startup._init_plugins()
     count = ctypes.c_ulonglong()
     platforms = core.BNGetPlatformList(count)
     try:
         for i in xrange(0, count.value):
             yield Platform(None, core.BNNewPlatformReference(platforms[i]))
     finally:
         core.BNFreePlatformList(platforms, count.value)
コード例 #18
0
	def os_list(self):
		startup._init_plugins()
		count = ctypes.c_ulonglong()
		platforms = core.BNGetPlatformOSList(count)
		result = []
		for i in xrange(0, count.value):
			result.append(str(platforms[i]))
		core.BNFreePlatformOSList(platforms, count.value)
		return result
コード例 #19
0
	def __iter__(self):
		startup._init_plugins()
		count = ctypes.c_ulonglong()
		xforms = core.BNGetTransformTypeList(count)
		try:
			for i in xrange(0, count.value):
				yield Transform(xforms[i])
		finally:
			core.BNFreeTransformTypeList(xforms)
コード例 #20
0
 def __iter__(self):
     startup._init_plugins()
     count = ctypes.c_ulonglong()
     tasks = core.BNGetRunningBackgroundTasks(count)
     try:
         for i in xrange(0, count.value):
             yield BackgroundTask(
                 core.BNNewBackgroundTaskReference(tasks[i]))
     finally:
         core.BNFreeBackgroundTaskList(tasks)
コード例 #21
0
	def register(cls):
		startup._init_plugins()
		if cls.name is None:
			raise ValueError("undo action 'name' not defined")
		if cls.action_type is None:
			raise ValueError("undo action 'action_type' not defined")
		cb_type = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.c_char_p, ctypes.POINTER(core.BNUndoAction))
		cls._registered_cb = cb_type(cls._deserialize)
		core.BNRegisterUndoActionType(cls.name, 0, cls._registered_cb)
		cls._registered = True
コード例 #22
0
 def list(self):
     """List all ScriptingProvider types (read-only)"""
     startup._init_plugins()
     count = ctypes.c_ulonglong()
     types = core.BNGetScriptingProviderList(count)
     result = []
     for i in xrange(0, count.value):
         result.append(ScriptingProvider(types[i]))
     core.BNFreeScriptingProviderList(types)
     return result
コード例 #23
0
	def list(self):
		"""List all ScriptingProvider types (read-only)"""
		startup._init_plugins()
		count = ctypes.c_ulonglong()
		types = core.BNGetScriptingProviderList(count)
		result = []
		for i in xrange(0, count.value):
			result.append(ScriptingProvider(types[i]))
		core.BNFreeScriptingProviderList(types)
		return result
コード例 #24
0
 def register(cls, name, description, action, is_valid=None):
     startup._init_plugins()
     action_obj = ctypes.CFUNCTYPE(
         None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView))(
             lambda ctxt, view: cls._default_action(view, action))
     is_valid_obj = ctypes.CFUNCTYPE(
         ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView))(
             lambda ctxt, view: cls._default_is_valid(view, is_valid))
     cls._registered_commands.append((action_obj, is_valid_obj))
     core.BNRegisterPluginCommand(name, description, action_obj,
                                  is_valid_obj, None)
コード例 #25
0
 def register_for_address(cls, name, description, action, is_valid=None):
     startup._init_plugins()
     action_obj = ctypes.CFUNCTYPE(
         None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView),
         ctypes.c_ulonglong)(lambda ctxt, view, addr: cls._address_action(
             view, addr, action))
     is_valid_obj = ctypes.CFUNCTYPE(
         ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView),
         ctypes.c_ulonglong)(lambda ctxt, view, addr: cls._address_is_valid(
             view, addr, is_valid))
     cls._registered_commands.append((action_obj, is_valid_obj))
     core.BNRegisterPluginCommandForAddress(name, description, action_obj,
                                            is_valid_obj, None)
コード例 #26
0
	def register(cls):
		startup._init_plugins()
		if cls.name is None:
			raise ValueError("transform 'name' is not defined")
		if cls.long_name is None:
			cls.long_name = cls.name
		if cls.transform_type is None:
			raise ValueError("transform 'transform_type' is not defined")
		if cls.group is None:
			cls.group = ""
		xform = cls(None)
		cls._registered_cb = xform._cb
		xform.handle = core.BNRegisterTransformType(cls.transform_type, cls.name, cls.long_name, cls.group, xform._cb)
コード例 #27
0
	def register(cls):
		startup._init_plugins()
		if cls.name is None:
			raise ValueError("transform 'name' is not defined")
		if cls.long_name is None:
			cls.long_name = cls.name
		if cls.transform_type is None:
			raise ValueError("transform 'transform_type' is not defined")
		if cls.group is None:
			cls.group = ""
		xform = cls(None)
		cls._registered_cb = xform._cb
		xform.handle = core.BNRegisterTransformType(cls.transform_type, cls.name, cls.long_name, cls.group, xform._cb)
コード例 #28
0
ファイル: update.py プロジェクト: joshwatson/binaryninja-api
	def __iter__(self):
		startup._init_plugins()
		count = ctypes.c_ulonglong()
		errors = ctypes.c_char_p()
		channels = core.BNGetUpdateChannels(count, errors)
		if errors:
			error_str = errors.value
			core.BNFreeString(ctypes.cast(errors, ctypes.POINTER(ctypes.c_byte)))
			raise IOError(error_str)
		try:
			for i in xrange(0, count.value):
				yield UpdateChannel(channels[i].name, channels[i].description, channels[i].latestVersion)
		finally:
			core.BNFreeUpdateChannelList(channels, count.value)
コード例 #29
0
	def get_list(cls, os = None, arch = None):
		startup._init_plugins()
		count = ctypes.c_ulonglong()
		if os is None:
			platforms = core.BNGetPlatformList(count)
		elif arch is None:
			platforms = core.BNGetPlatformListByOS(os)
		else:
			platforms = core.BNGetPlatformListByArchitecture(os, arch.handle)
		result = []
		for i in xrange(0, count.value):
			result.append(Platform(None, core.BNNewPlatformReference(platforms[i])))
		core.BNFreePlatformList(platforms, count.value)
		return result
コード例 #30
0
ファイル: update.py プロジェクト: joshwatson/binaryninja-api
	def list(self):
		startup._init_plugins()
		count = ctypes.c_ulonglong()
		errors = ctypes.c_char_p()
		channels = core.BNGetUpdateChannels(count, errors)
		if errors:
			error_str = errors.value
			core.BNFreeString(ctypes.cast(errors, ctypes.POINTER(ctypes.c_byte)))
			raise IOError(error_str)
		result = []
		for i in xrange(0, count.value):
			result.append(UpdateChannel(channels[i].name, channels[i].description, channels[i].latestVersion))
		core.BNFreeUpdateChannelList(channels, count.value)
		return result
コード例 #31
0
	def get_list(cls, os = None, arch = None):
		startup._init_plugins()
		count = ctypes.c_ulonglong()
		if os is None:
			platforms = core.BNGetPlatformList(count)
		elif arch is None:
			platforms = core.BNGetPlatformListByOS(os)
		else:
			platforms = core.BNGetPlatformListByArchitecture(os, arch.handle)
		result = []
		for i in xrange(0, count.value):
			result.append(Platform(None, core.BNNewPlatformReference(platforms[i])))
		core.BNFreePlatformList(platforms, count.value)
		return result
コード例 #32
0
    def __init__(self, filename=None, handle=None):
        """
		Instantiates a new FileMetadata class.

		:param filename: The string path to the file to be opened. Defaults to None.
		:param handle: A handle to the underlying C FileMetadata object. Defaults to None.
		"""
        if handle is not None:
            self.handle = core.handle_of_type(handle, core.BNFileMetadata)
        else:
            startup._init_plugins()
            self.handle = core.BNCreateFileMetadata()
            if filename is not None:
                core.BNSetFilename(self.handle, str(filename))
        self.nav = None
コード例 #33
0
	def __init__(self, filename = None, handle = None):
		"""
		Instantiates a new FileMetadata class.

		:param filename: The string path to the file to be opened. Defaults to None.
		:param handle: A handle to the underlying C FileMetadata object. Defaults to None.
		"""
		if handle is not None:
			self.handle = core.handle_of_type(handle, core.BNFileMetadata)
		else:
			startup._init_plugins()
			self.handle = core.BNCreateFileMetadata()
			if filename is not None:
				core.BNSetFilename(self.handle, str(filename))
		self.nav = None
コード例 #34
0
 def __iter__(self):
     startup._init_plugins()
     count = ctypes.c_ulonglong()
     errors = ctypes.c_char_p()
     channels = core.BNGetUpdateChannels(count, errors)
     if errors:
         error_str = errors.value
         core.BNFreeString(
             ctypes.cast(errors, ctypes.POINTER(ctypes.c_byte)))
         raise IOError(error_str)
     try:
         for i in xrange(0, count.value):
             yield UpdateChannel(channels[i].name, channels[i].description,
                                 channels[i].latestVersion)
     finally:
         core.BNFreeUpdateChannelList(channels, count.value)
コード例 #35
0
 def list(self):
     startup._init_plugins()
     count = ctypes.c_ulonglong()
     errors = ctypes.c_char_p()
     channels = core.BNGetUpdateChannels(count, errors)
     if errors:
         error_str = errors.value
         core.BNFreeString(
             ctypes.cast(errors, ctypes.POINTER(ctypes.c_byte)))
         raise IOError(error_str)
     result = []
     for i in xrange(0, count.value):
         result.append(
             UpdateChannel(channels[i].name, channels[i].description,
                           channels[i].latestVersion))
     core.BNFreeUpdateChannelList(channels, count.value)
     return result
コード例 #36
0
ファイル: update.py プロジェクト: joshwatson/binaryninja-api
	def __getitem__(cls, name):
		startup._init_plugins()
		count = ctypes.c_ulonglong()
		errors = ctypes.c_char_p()
		channels = core.BNGetUpdateChannels(count, errors)
		if errors:
			error_str = errors.value
			core.BNFreeString(ctypes.cast(errors, ctypes.POINTER(ctypes.c_byte)))
			raise IOError(error_str)
		result = None
		for i in xrange(0, count.value):
			if channels[i].name == str(name):
				result = UpdateChannel(channels[i].name, channels[i].description, channels[i].latestVersion)
				break
		core.BNFreeUpdateChannelList(channels, count.value)
		if result is None:
			raise KeyError("'%s' is not a valid channel" % str(name))
		return result
コード例 #37
0
 def __getitem__(cls, name):
     startup._init_plugins()
     count = ctypes.c_ulonglong()
     errors = ctypes.c_char_p()
     channels = core.BNGetUpdateChannels(count, errors)
     if errors:
         error_str = errors.value
         core.BNFreeString(
             ctypes.cast(errors, ctypes.POINTER(ctypes.c_byte)))
         raise IOError(error_str)
     result = None
     for i in xrange(0, count.value):
         if channels[i].name == str(name):
             result = UpdateChannel(channels[i].name,
                                    channels[i].description,
                                    channels[i].latestVersion)
             break
     core.BNFreeUpdateChannelList(channels, count.value)
     if result is None:
         raise KeyError("'%s' is not a valid channel" % str(name))
     return result
コード例 #38
0
ファイル: plugin.py プロジェクト: mattz0rt/binaryninja-api
    def register(cls, name, description, action, is_valid=None):
        """
		``register`` Register a plugin

		:param str name: name of the plugin
		:param str description: description of the plugin
		:param action: function to call with the ``BinaryView`` as an argument
		:param is_valid: optional argument of a function passed a ``BinaryView`` to determine whether the plugin should be enabled for that view
		:rtype: None

		.. warning:: Calling ``register`` with the same function name will replace the existing function but will leak the memory of the original plugin.
		"""
        startup._init_plugins()
        action_obj = ctypes.CFUNCTYPE(
            None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView))(
                lambda ctxt, view: cls._default_action(view, action))
        is_valid_obj = ctypes.CFUNCTYPE(
            ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView))(
                lambda ctxt, view: cls._default_is_valid(view, is_valid))
        cls._registered_commands.append((action_obj, is_valid_obj))
        core.BNRegisterPluginCommand(name, description, action_obj,
                                     is_valid_obj, None)
コード例 #39
0
ファイル: plugin.py プロジェクト: joshwatson/binaryninja-api
	def register_for_function(cls, name, description, action, is_valid = None):
		startup._init_plugins()
		action_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNFunction))(lambda ctxt, view, func: cls._function_action(view, func, action))
		is_valid_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.POINTER(core.BNFunction))(lambda ctxt, view, func: cls._function_is_valid(view, func, is_valid))
		cls._registered_commands.append((action_obj, is_valid_obj))
		core.BNRegisterPluginCommandForFunction(name, description, action_obj, is_valid_obj, None)
コード例 #40
0
	def __getitem__(self, value):
		startup._init_plugins()
		provider = core.BNGetScriptingProviderByName(str(value))
		if provider is None:
			raise KeyError("'%s' is not a valid scripting provider" % str(value))
		return ScriptingProvider(provider)
コード例 #41
0
 def __getitem__(cls, name):
     startup._init_plugins()
     xform = core.BNGetTransformByName(name)
     if xform is None:
         raise KeyError("'%s' is not a valid transform" % str(name))
     return Transform(xform)
コード例 #42
0
 def __getitem__(cls, value):
     startup._init_plugins()
     platform = core.BNGetPlatformByName(str(value))
     if platform is None:
         raise KeyError("'%s' is not a valid platform" % str(value))
     return Platform(None, platform)
コード例 #43
0
	def __getitem__(cls, name):
		startup._init_plugins()
		xform = core.BNGetTransformByName(name)
		if xform is None:
			raise KeyError("'%s' is not a valid transform" % str(name))
		return Transform(xform)
コード例 #44
0
ファイル: plugin.py プロジェクト: joshwatson/binaryninja-api
	def register_for_range(cls, name, description, action, is_valid = None):
		startup._init_plugins()
		action_obj = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.c_ulonglong, ctypes.c_ulonglong)(lambda ctxt, view, addr, length: cls._range_action(view, addr, length, action))
		is_valid_obj = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_void_p, ctypes.POINTER(core.BNBinaryView), ctypes.c_ulonglong, ctypes.c_ulonglong)(lambda ctxt, view, addr, length: cls._range_is_valid(view, addr, length, is_valid))
		cls._registered_commands.append((action_obj, is_valid_obj))
		core.BNRegisterPluginCommandForRange(name, description, action_obj, is_valid_obj, None)
コード例 #45
0
	def __getitem__(cls, value):
		startup._init_plugins()
		platform = core.BNGetPlatformByName(str(value))
		if platform is None:
			raise KeyError("'%s' is not a valid platform" % str(value))
		return Platform(None, platform)
コード例 #46
0
 def default_repository(self):
     """Gets the default Repository"""
     startup._init_plugins()
     return Repository(
         handle=core.BNRepositoryManagerGetDefaultRepository(self.handle))