scriptingprovider module¶
Class |
Description |
---|---|
dict() -> new empty dictionary |
|
- class BlacklistedDict[source]
Bases:
dict
- __init__(blacklist, *args)[source]
- add_blacklist_item(item)[source]
- enable_blacklist(enabled)[source]
- is_blacklisted_item(item)[source]
- remove_blacklist_item(item)[source]
- property blacklist_enabled
- class PythonScriptingInstance[source]
Bases:
ScriptingInstance
- class InterpreterThread[source]
Bases:
Thread
- __init__(instance)[source]
This constructor should always be called with keyword arguments. Arguments are:
group should be None; reserved for future extension when a ThreadGroup class is implemented.
target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.
name is the thread name. By default, a unique name is constructed of the form “Thread-N” where N is a small decimal number.
args is the argument tuple for the target invocation. Defaults to ().
kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.
If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread.
- add_input(data)[source]
- apply_locals()[source]
- end()[source]
- execute(_code)[source]
- get_selected_data()[source]
- read(size)[source]
- run()[source]
Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
- update_locals()[source]
- update_magic_variables()[source]
- write_at_cursor(data)[source]
- __init__(provider)[source]
- abstract perform_cancel_script_input()[source]
- abstract perform_complete_input(text, state)[source]
- abstract perform_execute_script_input(text)[source]
- abstract perform_execute_script_input_from_filename(filename)[source]
- abstract perform_set_current_address(addr)[source]
- abstract perform_set_current_basic_block(block)[source]
- abstract perform_set_current_binary_view(view)[source]
- abstract perform_set_current_function(func)[source]
- abstract perform_set_current_selection(begin, end)[source]
- abstract perform_stop()[source]
- class PythonScriptingProvider[source]
Bases:
ScriptingProvider
- class MagicVariable[source]
Bases:
object
Represents an automatically-populated (magic) variable in the python scripting console
- __init__(get_value: Callable[[PythonScriptingInstance], Any], set_value: Callable[[PythonScriptingInstance, Any, Any], None] | None, depends_on: List[str]) None
- Parameters:
get_value (Callable[[PythonScriptingInstance], Any]) –
set_value (Callable[[PythonScriptingInstance, Any, Any], None] | None) –
- Return type:
None
- get_value: Callable[[PythonScriptingInstance], Any]
Function to call, before every time a script is evaluated, to get the value of the variable
- set_value: Callable[[PythonScriptingInstance, Any, Any], None] | None
(Optional) function to call after a script is evaluated, if the value of the variable has changed during the course of the script. If None, a warning will be printed stating that the variable is read-only. Signature: (instance: PythonScriptingInstance, old_value: any, new_value: any) -> None
- instance_class
alias of
PythonScriptingInstance
- classmethod register_magic_variable(name: str, get_value: Callable[[PythonScriptingInstance], Any], set_value: Callable[[PythonScriptingInstance, Any, Any], None] | None = None, depends_on: List[str] | None = None)[source]
Add a magic variable to all scripting instances created by the scripting provider :param name: Variable name identifier to be used in the interpreter :param get_value: Function to call, before every time a script is evaluated, to get the value of the variable :param set_value: (Optional) Function to call after a script is evaluated, if the value of the variable has changed during the course of the script. If None, a warning will be printed stating that the variable is read-only. Signature: (instance: PythonScriptingInstance, old_value: any, new_value: any) -> None :param depends_on: List of other variables whose values on which this variable’s value depends
- Parameters:
name (str) –
get_value (Callable[[PythonScriptingInstance], Any]) –
set_value (Callable[[PythonScriptingInstance, Any, Any], None] | None) –
- classmethod unregister_magic_variable(name: str)[source]
Remove a magic variable by name :param name: Variable name
- Parameters:
name (str) –
- apiName = 'python3'
- magic_variables: Dict[str, MagicVariable] = {'bv': PythonScriptingProvider.MagicVariable(get_value=<function <lambda>>, set_value=None, depends_on=[]), 'current_address': PythonScriptingProvider.MagicVariable(get_value=<function _get_here>, set_value=<function _set_here>, depends_on=['current_ui_context']), 'current_basic_block': PythonScriptingProvider.MagicVariable(get_value=<function <lambda>>, set_value=None, depends_on=[]), 'current_comment': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_comment>, set_value=<function _set_current_comment>, depends_on=[]), 'current_data_var': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_data_var>, set_value=None, depends_on=[]), 'current_function': PythonScriptingProvider.MagicVariable(get_value=<function <lambda>>, set_value=None, depends_on=[]), 'current_hlil': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_hlil>, set_value=None, depends_on=[]), 'current_hlil_ssa': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_hlil_ssa>, set_value=None, depends_on=['current_hlil']), 'current_il_basic_block': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_il_basic_block>, set_value=None, depends_on=['current_il_instruction']), 'current_il_expr': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_il_expr>, set_value=None, depends_on=['current_il_expr_index', 'current_il_function']), 'current_il_expr_index': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_il_expr_index>, set_value=None, depends_on=['current_token']), 'current_il_function': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_il_function>, set_value=None, depends_on=['current_ui_view_location', 'current_llil', 'current_lifted_il', 'current_llil_ssa', 'current_mapped_mlil', 'current_mapped_mlil_ssa', 'current_mlil', 'current_mlil_ssa', 'current_hlil', 'current_hlil_ssa']), 'current_il_index': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_il_index>, set_value=None, depends_on=['current_ui_view_location']), 'current_il_instruction': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_il_instruction>, set_value=None, depends_on=['current_il_index', 'current_il_function']), 'current_il_instructions': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_il_instructions>, set_value=None, depends_on=['current_il_index', 'current_il_function', 'current_ui_view']), 'current_lifted_il': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_lifted_il>, set_value=None, depends_on=[]), 'current_llil': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_llil>, set_value=None, depends_on=[]), 'current_llil_ssa': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_llil_ssa>, set_value=None, depends_on=['current_llil']), 'current_mapped_mlil': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_mapped_mlil>, set_value=None, depends_on=[]), 'current_mapped_mlil_ssa': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_mapped_mlil_ssa>, set_value=None, depends_on=['current_mapped_mlil']), 'current_mlil': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_mlil>, set_value=None, depends_on=[]), 'current_mlil_ssa': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_mlil_ssa>, set_value=None, depends_on=['current_mlil']), 'current_project': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_project>, set_value=None, depends_on=['current_ui_context', 'current_view']), 'current_raw_offset': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_raw_offset>, set_value=<function _set_current_raw_offset>, depends_on=['current_ui_context']), 'current_sections': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_sections>, set_value=None, depends_on=[]), 'current_segment': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_segment>, set_value=None, depends_on=[]), 'current_selection': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_selection>, set_value=<function _set_current_selection>, depends_on=['current_ui_view']), 'current_symbol': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_symbol>, set_value=None, depends_on=[]), 'current_symbols': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_symbols>, set_value=None, depends_on=[]), 'current_thread': PythonScriptingProvider.MagicVariable(get_value=<function <lambda>>, set_value=None, depends_on=[]), 'current_token': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_token>, set_value=None, depends_on=['current_ui_token_state']), 'current_ui_action_context': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_ui_action_context>, set_value=None, depends_on=['current_ui_view', 'current_ui_action_handler']), 'current_ui_action_handler': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_ui_action_handler>, set_value=None, depends_on=['current_ui_context']), 'current_ui_context': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_ui_context>, set_value=None, depends_on=[]), 'current_ui_token_state': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_ui_token_state>, set_value=None, depends_on=['current_ui_action_context']), 'current_ui_view': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_ui_view>, set_value=None, depends_on=['current_ui_context']), 'current_ui_view_frame': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_ui_view_frame>, set_value=None, depends_on=['current_ui_context']), 'current_ui_view_location': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_ui_view_location>, set_value=None, depends_on=['current_ui_view_frame']), 'current_variable': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_variable>, set_value=None, depends_on=['current_ui_token_state']), 'current_view': PythonScriptingProvider.MagicVariable(get_value=<function <lambda>>, set_value=None, depends_on=[]), 'dbg': PythonScriptingProvider.MagicVariable(get_value=<function <lambda>>, set_value=None, depends_on=[]), 'here': PythonScriptingProvider.MagicVariable(get_value=<function _get_here>, set_value=<function _set_here>, depends_on=['current_ui_context'])}
- name = 'Python'
- class ScriptingInstance[source]
Bases:
object
- __init__(provider, handle=None)[source]
- cancel_script_input(text)[source]
- complete_input(text, state)[source]
- error(text)[source]
- execute_script_input(text)[source]
- execute_script_input_from_filename(filename)[source]
- output(text)[source]
- abstract perform_cancel_script_input()[source]
- abstract perform_execute_script_input(text)[source]
- abstract perform_execute_script_input_from_filename(text)[source]
- abstract perform_set_current_address(addr)[source]
- abstract perform_set_current_basic_block(block)[source]
- abstract perform_set_current_binary_view(view)[source]
- abstract perform_set_current_function(func)[source]
- abstract perform_set_current_selection(begin, end)[source]
- abstract perform_stop()[source]
- register_output_listener(listener)[source]
- set_current_address(addr)[source]
- set_current_basic_block(block)[source]
- set_current_binary_view(view)[source]
- set_current_function(func)[source]
- set_current_selection(begin, end)[source]
- stop()[source]
- unregister_output_listener(listener)[source]
- warning(text)[source]
- property delimiters
- property input_ready_state
- class ScriptingOutputListener[source]
Bases:
object
- notify_error(text)[source]
- notify_input_ready_state_changed(state)[source]
- notify_output(text)[source]
- notify_warning(text)[source]
- class ScriptingProvider[source]
Bases:
object
- __init__(handle=None)[source]
- create_instance() ScriptingInstance | None [source]
- Return type:
ScriptingInstance | None
- apiName = ''
- instance_class: Type[ScriptingInstance] | None = None
- name = ''
- bninspect(code_, globals_, locals_)[source]
bninspect
prints documentation about a command that is about to be run The interpreter will invoke this function if you input a line ending in ? e.g. bv?
- redirect_stdio()[source]
BlacklistedDict¶
PythonScriptingInstance¶
- class PythonScriptingInstance[source]¶
Bases:
ScriptingInstance
- class InterpreterThread[source]¶
Bases:
Thread
- __init__(instance)[source]¶
This constructor should always be called with keyword arguments. Arguments are:
group should be None; reserved for future extension when a ThreadGroup class is implemented.
target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.
name is the thread name. By default, a unique name is constructed of the form “Thread-N” where N is a small decimal number.
args is the argument tuple for the target invocation. Defaults to ().
kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.
If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread.
- run()[source]¶
Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
PythonScriptingProvider¶
- class PythonScriptingProvider[source]¶
Bases:
ScriptingProvider
- class MagicVariable[source]¶
Bases:
object
Represents an automatically-populated (magic) variable in the python scripting console
- __init__(get_value: Callable[[PythonScriptingInstance], Any], set_value: Callable[[PythonScriptingInstance, Any, Any], None] | None, depends_on: List[str]) None ¶
- Parameters:
get_value (Callable[[PythonScriptingInstance], Any]) –
set_value (Callable[[PythonScriptingInstance, Any, Any], None] | None) –
- Return type:
None
- get_value: Callable[[PythonScriptingInstance], Any]¶
Function to call, before every time a script is evaluated, to get the value of the variable
- set_value: Callable[[PythonScriptingInstance, Any, Any], None] | None¶
(Optional) function to call after a script is evaluated, if the value of the variable has changed during the course of the script. If None, a warning will be printed stating that the variable is read-only. Signature: (instance: PythonScriptingInstance, old_value: any, new_value: any) -> None
- instance_class¶
alias of
PythonScriptingInstance
- classmethod register_magic_variable(name: str, get_value: Callable[[PythonScriptingInstance], Any], set_value: Callable[[PythonScriptingInstance, Any, Any], None] | None = None, depends_on: List[str] | None = None)[source]¶
Add a magic variable to all scripting instances created by the scripting provider :param name: Variable name identifier to be used in the interpreter :param get_value: Function to call, before every time a script is evaluated, to get the value of the variable :param set_value: (Optional) Function to call after a script is evaluated, if the value of the variable has changed during the course of the script. If None, a warning will be printed stating that the variable is read-only. Signature: (instance: PythonScriptingInstance, old_value: any, new_value: any) -> None :param depends_on: List of other variables whose values on which this variable’s value depends
- Parameters:
name (str) –
get_value (Callable[[PythonScriptingInstance], Any]) –
set_value (Callable[[PythonScriptingInstance, Any, Any], None] | None) –
- classmethod unregister_magic_variable(name: str)[source]¶
Remove a magic variable by name :param name: Variable name
- Parameters:
name (str) –
- apiName = 'python3'¶
- magic_variables: Dict[str, MagicVariable] = {'bv': PythonScriptingProvider.MagicVariable(get_value=<function <lambda>>, set_value=None, depends_on=[]), 'current_address': PythonScriptingProvider.MagicVariable(get_value=<function _get_here>, set_value=<function _set_here>, depends_on=['current_ui_context']), 'current_basic_block': PythonScriptingProvider.MagicVariable(get_value=<function <lambda>>, set_value=None, depends_on=[]), 'current_comment': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_comment>, set_value=<function _set_current_comment>, depends_on=[]), 'current_data_var': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_data_var>, set_value=None, depends_on=[]), 'current_function': PythonScriptingProvider.MagicVariable(get_value=<function <lambda>>, set_value=None, depends_on=[]), 'current_hlil': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_hlil>, set_value=None, depends_on=[]), 'current_hlil_ssa': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_hlil_ssa>, set_value=None, depends_on=['current_hlil']), 'current_il_basic_block': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_il_basic_block>, set_value=None, depends_on=['current_il_instruction']), 'current_il_expr': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_il_expr>, set_value=None, depends_on=['current_il_expr_index', 'current_il_function']), 'current_il_expr_index': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_il_expr_index>, set_value=None, depends_on=['current_token']), 'current_il_function': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_il_function>, set_value=None, depends_on=['current_ui_view_location', 'current_llil', 'current_lifted_il', 'current_llil_ssa', 'current_mapped_mlil', 'current_mapped_mlil_ssa', 'current_mlil', 'current_mlil_ssa', 'current_hlil', 'current_hlil_ssa']), 'current_il_index': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_il_index>, set_value=None, depends_on=['current_ui_view_location']), 'current_il_instruction': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_il_instruction>, set_value=None, depends_on=['current_il_index', 'current_il_function']), 'current_il_instructions': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_il_instructions>, set_value=None, depends_on=['current_il_index', 'current_il_function', 'current_ui_view']), 'current_lifted_il': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_lifted_il>, set_value=None, depends_on=[]), 'current_llil': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_llil>, set_value=None, depends_on=[]), 'current_llil_ssa': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_llil_ssa>, set_value=None, depends_on=['current_llil']), 'current_mapped_mlil': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_mapped_mlil>, set_value=None, depends_on=[]), 'current_mapped_mlil_ssa': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_mapped_mlil_ssa>, set_value=None, depends_on=['current_mapped_mlil']), 'current_mlil': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_mlil>, set_value=None, depends_on=[]), 'current_mlil_ssa': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_mlil_ssa>, set_value=None, depends_on=['current_mlil']), 'current_project': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_project>, set_value=None, depends_on=['current_ui_context', 'current_view']), 'current_raw_offset': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_raw_offset>, set_value=<function _set_current_raw_offset>, depends_on=['current_ui_context']), 'current_sections': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_sections>, set_value=None, depends_on=[]), 'current_segment': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_segment>, set_value=None, depends_on=[]), 'current_selection': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_selection>, set_value=<function _set_current_selection>, depends_on=['current_ui_view']), 'current_symbol': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_symbol>, set_value=None, depends_on=[]), 'current_symbols': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_symbols>, set_value=None, depends_on=[]), 'current_thread': PythonScriptingProvider.MagicVariable(get_value=<function <lambda>>, set_value=None, depends_on=[]), 'current_token': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_token>, set_value=None, depends_on=['current_ui_token_state']), 'current_ui_action_context': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_ui_action_context>, set_value=None, depends_on=['current_ui_view', 'current_ui_action_handler']), 'current_ui_action_handler': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_ui_action_handler>, set_value=None, depends_on=['current_ui_context']), 'current_ui_context': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_ui_context>, set_value=None, depends_on=[]), 'current_ui_token_state': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_ui_token_state>, set_value=None, depends_on=['current_ui_action_context']), 'current_ui_view': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_ui_view>, set_value=None, depends_on=['current_ui_context']), 'current_ui_view_frame': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_ui_view_frame>, set_value=None, depends_on=['current_ui_context']), 'current_ui_view_location': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_ui_view_location>, set_value=None, depends_on=['current_ui_view_frame']), 'current_variable': PythonScriptingProvider.MagicVariable(get_value=<function _get_current_variable>, set_value=None, depends_on=['current_ui_token_state']), 'current_view': PythonScriptingProvider.MagicVariable(get_value=<function <lambda>>, set_value=None, depends_on=[]), 'dbg': PythonScriptingProvider.MagicVariable(get_value=<function <lambda>>, set_value=None, depends_on=[]), 'here': PythonScriptingProvider.MagicVariable(get_value=<function _get_here>, set_value=<function _set_here>, depends_on=['current_ui_context'])}¶
- name = 'Python'¶