GeezerVison is showing api.binary.ninja — plugin module — Binary Ninja API Documentation v6.0.10905
plugin module¶
BackgroundTask¶
-
class BackgroundTask[source]¶
Bases: object
The BackgroundTask class provides a mechanism for reporting progress of
an optionally cancelable task to the user via the status bar in the UI.
If can_cancel is is True, then the task can be cancelled either
programmatically (via cancel) or by the user via the UI.
Note this class does not provide a means to execute a task, which is
available via the BackgroundTaskThread class.
- Parameters:
initial_progress_text – text description of the task to display in the status bar in the UI, defaults to “”
can_cancel – whether to enable cancellation of the task, defaults to False
-
__init__(initial_progress_text: str = '', can_cancel: bool = False, handle=None)[source]¶
- Parameters:
-
-
cancel()[source]¶
-
finish()[source]¶
-
property can_cancel¶
Whether the task can be cancelled (read-only)
-
property cancelled¶
Whether the task has been cancelled
-
property finished¶
Whether the task has finished
-
property progress¶
Text description of the progress of the background task (displayed in status bar of the UI)
BackgroundTaskThread¶
-
class BackgroundTaskThread[source]¶
Bases: BackgroundTask
The BackgroundTaskThread class provides an all-in-one solution for executing a BackgroundTask
in a thread.
See the BackgroundTask for additional information.
- Parameters:
initial_progress_text – text description of the task to display in the status bar in the UI, defaults to “”
can_cancel – whether to enable cancellation of the task, defaults to False
-
__init__(initial_progress_text: str = '', can_cancel: bool = False)[source]¶
- Parameters:
-
-
join(timeout=None)[source]¶
-
run()[source]¶
-
start()[source]¶
PluginCommand¶
-
class PluginCommand[source]¶
Bases: object
The class PluginCommand contains all the plugin registration methods as class methods.
You shouldn’t need to create an instance of this class, instead see register,
register_for_address, register_for_function, and similar class methods for examples
on how to register your plugin.
-
__init__(cmd)[source]¶
-
execute(context: PluginCommandContext)[source]¶
execute Execute a plugin. See the example in PluginCommandContext
- Parameters:
context (str) – PluginCommandContext to pass the PluginCommand
- Return type:
None
>>> ctx = PluginCommandContext(bv);
>>> PluginCommand.get_valid_list(ctx)[r'PDB\Load'].execute(ctx)
-
classmethod get_valid_list(context: PluginCommandContext)[source]¶
Dict of registered plugins
- Parameters:
context (PluginCommandContext)
-
is_valid(context: PluginCommandContext)[source]¶
- Parameters:
context (PluginCommandContext)
-
classmethod register(name: str, description: str, action: Callable[[BinaryView], None], is_valid: Callable[[BinaryView], bool] | None = None)[source]¶
register Register a plugin
- Parameters:
name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)
description (str) – description of the plugin
action (callback) – function to call with the BinaryView as an argument
is_valid (callback) – optional argument of a function passed a BinaryView to determine whether the plugin should be enabled for that view
- Return type:
None
- Example:
>>> def my_plugin(bv: BinaryView):
>>> log_info(f"My plugin was called on bv: `{bv}`")
>>> PluginCommand.register("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView) -> bool:
>>> return False
>>> PluginCommand.register("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True
Warning
Calling register with the same function name will replace the existing function but will leak the memory of the original plugin.
-
classmethod register_for_address(name: str, description: str, action: Callable[[BinaryView, int], None], is_valid: Callable[[BinaryView, int], bool] | None = None)[source]¶
register_for_address Register a plugin to be called with an address argument
- Parameters:
name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)
description (str) – description of the plugin
action (callback) – function to call with the BinaryView and address as arguments
is_valid (callback) – optional argument of a function passed a BinaryView and address to determine whether the plugin should be enabled for that view
- Return type:
None
- Example:
>>> def my_plugin(bv: BinaryView, address: int):
>>> log_info(f"My plugin was called on bv: `{bv}` at address {hex(address)}")
>>> PluginCommand.register_for_address("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView, address: int) -> bool:
>>> return False
>>> PluginCommand.register_for_address("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True
Warning
Calling register_for_address with the same function name will replace the existing function but will leak the memory of the original plugin.
-
classmethod register_for_function(name: str, description: str, action: Callable[[BinaryView, Function], None], is_valid: Callable[[BinaryView, Function], bool] | None = None)[source]¶
register_for_function Register a plugin to be called with a function argument
- Parameters:
name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)
description (str) – description of the plugin
action (callback) – function to call with the BinaryView and a Function as arguments
is_valid (callback) – optional argument of a function passed a BinaryView and Function to determine whether the plugin should be enabled for that view
- Return type:
None
- Example:
>>> def my_plugin(bv: BinaryView, func: Function):
>>> log_info(f"My plugin was called on func {func} in bv `{bv}`")
>>> PluginCommand.register_for_function("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView, func: Function) -> bool:
>>> return False
>>> PluginCommand.register_for_function("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True
Warning
Calling register_for_function with the same function name will replace the existing function but will leak the memory of the original plugin.
-
classmethod register_for_high_level_il_function(name: str, description: str, action: Callable[[BinaryView, HighLevelILFunction], None], is_valid: Callable[[BinaryView, HighLevelILFunction], bool] | None = None)[source]¶
register_for_high_level_il_function Register a plugin to be called with a high level IL function argument
- Parameters:
name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)
description (str) – description of the plugin
action (callback) – function to call with the BinaryView and a HighLevelILFunction as arguments
is_valid (callback) – optional argument of a function passed a BinaryView and HighLevelILFunction to determine whether the plugin should be enabled for that view
- Return type:
None
- Example:
>>> def my_plugin(bv: BinaryView, func: HighLevelILFunction):
>>> log_info(f"My plugin was called on func {func} in bv `{bv}`")
>>> PluginCommand.register_for_high_level_il_function("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView, func: HighLevelILFunction) -> bool:
>>> return False
>>> PluginCommand.register_for_high_level_il_function("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True
Warning
Calling register_for_high_level_il_function with the same function name will replace the existing function but will leak the memory of the original plugin.
-
classmethod register_for_high_level_il_instruction(name: str, description: str, action: Callable[[BinaryView, HighLevelILInstruction], None], is_valid: Callable[[BinaryView, HighLevelILInstruction], bool] | None = None)[source]¶
register_for_high_level_il_instruction Register a plugin to be called with a high level IL instruction argument
- Parameters:
name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)
description (str) – description of the plugin
action (callback) – function to call with the BinaryView and a HighLevelILInstruction as arguments
is_valid (callback) – optional argument of a function passed a BinaryView and HighLevelILInstruction to determine whether the plugin should be enabled for that view
- Return type:
None
- Example:
>>> def my_plugin(bv: BinaryView, inst: HighLevelILInstruction):
>>> log_info(f"My plugin was called on inst {inst} in bv `{bv}`")
>>> PluginCommand.register_for_high_level_il_instruction("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView, inst: HighLevelILInstruction) -> bool:
>>> return False
>>> PluginCommand.register_for_high_level_il_instruction("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True
Warning
Calling register_for_high_level_il_instruction with the same function name will replace the existing function but will leak the memory of the original plugin.
-
classmethod register_for_low_level_il_function(name: str, description: str, action: Callable[[BinaryView, LowLevelILFunction], None], is_valid: Callable[[BinaryView, LowLevelILFunction], bool] | None = None)[source]¶
register_for_low_level_il_function Register a plugin to be called with a low level IL function argument
- Parameters:
name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)
description (str) – description of the plugin
action (callback) – function to call with the BinaryView and a LowLevelILFunction as arguments
is_valid (callback) – optional argument of a function passed a BinaryView and LowLevelILFunction to determine whether the plugin should be enabled for that view
- Return type:
None
- Example:
>>> def my_plugin(bv: BinaryView, func: LowLevelILFunction):
>>> log_info(f"My plugin was called on func {func} in bv `{bv}`")
>>> PluginCommand.register_for_low_level_il_function("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView, func: LowLevelILFunction) -> bool:
>>> return False
>>> PluginCommand.register_for_low_level_il_function("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True
Warning
Calling register_for_low_level_il_function with the same function name will replace the existing function but will leak the memory of the original plugin.
-
classmethod register_for_low_level_il_instruction(name: str, description: str, action: Callable[[BinaryView, LowLevelILInstruction], None], is_valid: Callable[[BinaryView, LowLevelILInstruction], bool] | None = None)[source]¶
register_for_low_level_il_instruction Register a plugin to be called with a low level IL instruction argument
- Parameters:
name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)
description (str) – description of the plugin
action (callback) – function to call with the BinaryView and a LowLevelILInstruction as arguments
is_valid (callback) – optional argument of a function passed a BinaryView and LowLevelILInstruction to determine whether the plugin should be enabled for that view
- Return type:
None
- Example:
>>> def my_plugin(bv: BinaryView, inst: LowLevelILInstruction):
>>> log_info(f"My plugin was called on inst {inst} in bv `{bv}`")
>>> PluginCommand.register_for_low_level_il_instruction("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView, inst: LowLevelILInstruction) -> bool:
>>> return False
>>> PluginCommand.register_for_low_level_il_instruction("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True
Warning
Calling register_for_low_level_il_instruction with the same function name will replace the existing function but will leak the memory of the original plugin.
-
classmethod register_for_medium_level_il_function(name: str, description: str, action: Callable[[BinaryView, MediumLevelILFunction], None], is_valid: Callable[[BinaryView, MediumLevelILFunction], bool] | None = None)[source]¶
register_for_medium_level_il_function Register a plugin to be called with a medium level IL function argument
- Parameters:
name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)
description (str) – description of the plugin
action (callback) – function to call with the BinaryView and a MediumLevelILFunction as arguments
is_valid (callback) – optional argument of a function passed a BinaryView and MediumLevelILFunction to determine whether the plugin should be enabled for that view
- Return type:
None
- Example:
>>> def my_plugin(bv: BinaryView, func: MediumLevelILFunction):
>>> log_info(f"My plugin was called on func {func} in bv `{bv}`")
>>> PluginCommand.register_for_medium_level_il_function("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView, func: MediumLevelILFunction) -> bool:
>>> return False
>>> PluginCommand.register_for_medium_level_il_function("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True
Warning
Calling register_for_medium_level_il_function with the same function name will replace the existing function but will leak the memory of the original plugin.
-
classmethod register_for_medium_level_il_instruction(name: str, description: str, action: Callable[[BinaryView, MediumLevelILInstruction], None], is_valid: Callable[[BinaryView, MediumLevelILInstruction], bool] | None = None)[source]¶
register_for_medium_level_il_instruction Register a plugin to be called with a medium level IL instruction argument
- Parameters:
name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)
description (str) – description of the plugin
action (callback) – function to call with the BinaryView and a MediumLevelILInstruction as arguments
is_valid (callback) – optional argument of a function passed a BinaryView and MediumLevelILInstruction to determine whether the plugin should be enabled for that view
- Return type:
None
- Example:
>>> def my_plugin(bv: BinaryView, inst: MediumLevelILInstruction):
>>> log_info(f"My plugin was called on inst {inst} in bv `{bv}`")
>>> PluginCommand.register_for_medium_level_il_instruction("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView, inst: MediumLevelILInstruction) -> bool:
>>> return False
>>> PluginCommand.register_for_medium_level_il_instruction("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True
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.
-
classmethod register_for_project(name: str, description: str, action: Callable[[Project], None], is_valid: Callable[[Project], bool] | None = None)[source]¶
register_for_project Register a plugin to be called with a project argument
- Parameters:
name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)
description (str) – description of the plugin
action (callback) – function to call with the Project as an argument
is_valid (callback) – optional argument of a function passed a Project to determine whether the plugin should be enabled for that project
- Return type:
None
- Example:
>>> def my_plugin(project: Project):
>>> log_info(f"My plugin was called on project: `{project}`")
>>> PluginCommand.register_for_project("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(project: Project) -> bool:
>>> return False
>>> PluginCommand.register_for_project("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True
Warning
Calling register_for_project with the same function name will replace the existing function but will leak the memory of the original plugin.
-
classmethod register_for_range(name: str, description: str, action: Callable[[BinaryView, int, int], None], is_valid: Callable[[BinaryView, int, int], bool] | None = None)[source]¶
register_for_range Register a plugin to be called with a range argument
- Parameters:
name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)
description (str) – description of the plugin
action (callback) – function to call with the BinaryView, start address, and length as arguments
is_valid (callback) – optional argument of a function passed a BinaryView, start address, and length to determine whether the plugin should be enabled for that view
- Return type:
None
- Example:
>>> def my_plugin(bv: BinaryView, start: int, length: int):
>>> log_info(f"My plugin was called on bv: `{bv}` at {hex(start)} of length {hex(length)}")
>>> PluginCommand.register_for_range("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView, start: int, length: int) -> bool:
>>> return False
>>> PluginCommand.register_for_range("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True
Warning
Calling register_for_range with the same function name will replace the existing function but will leak the memory of the original plugin.
-
classmethod register_global(name: str, description: str, action: Callable[[], None], is_valid: Callable[[], bool] | None = None)[source]¶
register_global Register a command globally
- Parameters:
name (str) – name of the command (use ‘Folder\Name’ to have the menu item nested in a folder)
description (str) – description of the command
action (callback) – function to call
is_valid (callback) – optional argument of a function to determine whether the command should be enabled
- Return type:
None
- Example:
>>> def my_command():
>>> log_info(f"My command was called on bv")
>>> PluginCommand.register_global("My Command", "My command description (not used)", my_command)
True
>>> def is_valid() -> bool:
>>> return False
>>> PluginCommand.register_global("My Command (With Valid Function)", "My command description (not used)", my_plugin, is_valid)
True
Warning
Calling register_global with the same function name will replace the existing function but will leak the memory of the original plugin.
-
property command¶
-
property description¶
-
property name¶
-
property type¶
PluginCommandContext¶
-
class PluginCommandContext[source]¶
Bases: object
The class PluginCommandContext is used to access loaded plugins and their exposed methods with the context of a specific Binary VIew.
- Example:
>>> bv = load("/tmp/file1")
>>> ctx = PluginCommandContext(bv);
>>> binexport = PluginCommand.get_valid_list(ctx)["BinExport"]
>>> binexport.execute(ctx)
-
__init__(view)[source]¶
-
property address¶
-
property function¶
-
property instruction¶
-
property length¶
-
property project¶
-
property view¶
|