interaction module¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- class AddressField(prompt: str, view: BinaryView | None = None, current_address: int = 0, default: int | None = None)[source]¶
Bases:
object
AddressField
prompts the user for an address. By passing the optional view and current_address parameters offsets can be used instead of just an address. The result is stored as in int in self.result.Note
This API currently functions differently on the command-line, as the view and current_address are disregarded. Additionally where as in the UI the result defaults to hexadecimal on the command-line 0x must be specified.
- Parameters:
prompt (str) –
view (BinaryView | None) –
current_address (int) –
default (int | None) –
- property current_address¶
current address to use as a base for relative calculations
- property prompt¶
prompt to be presented to the user
- property result¶
- property view¶
BinaryView for the address
- class ChoiceField(prompt: str, choices: List[str], default: str | None = None)[source]¶
Bases:
object
ChoiceField
prompts the user to choose from the list of strings provided inchoices
. Result is stored in self.result as an index in to the choices array.- Attr str prompt:
prompt to be presented to the user
- Attr list(str) choices:
list of choices to choose from
- Parameters:
- property choices¶
- property prompt¶
- property result¶
- class DirectoryNameField(prompt, default_name='', default=None)[source]¶
Bases:
object
DirectoryNameField
prompts the user to specify a directory name to open. Result is stored in self.result as a string.- property default_name¶
- property prompt¶
- property result¶
- class FlowGraphReport(title, graph, view=None)[source]¶
Bases:
object
- property graph¶
- property title¶
- property view¶
- class HTMLReport(title, contents, plaintext='', view=None)[source]¶
Bases:
object
- property contents¶
- property plaintext¶
- property title¶
- property view¶
- class IntegerField(prompt: str, default: int | None = None)[source]¶
Bases:
object
IntegerField
add prompt for integer. Result is stored in self.result as an int.- property prompt¶
- property result¶
- class InteractionHandler[source]¶
Bases:
object
- class LabelField(text: str)[source]¶
Bases:
object
LabelField
adds a text label to the display.- Parameters:
text (str) –
- class MarkdownReport(title, contents, plaintext='', view=None)[source]¶
Bases:
object
- property contents¶
- property plaintext¶
- property title¶
- property view¶
- class MultilineTextField(prompt: str, default: str | None = None)[source]¶
Bases:
object
MultilineTextField
add multi-line text string input field. Result is stored in self.result as a string. This option is not supported on the command-line.- property prompt¶
- property result¶
- class OpenFileNameField(prompt: str, ext: str = '', default: str | None = None)[source]¶
Bases:
object
OpenFileNameField
prompts the user to specify a file name to open. Result is stored in self.result as a string.- property ext¶
- property prompt¶
- property result¶
- class PlainTextReport(title, contents, view=None)[source]¶
Bases:
object
- property contents¶
- property title¶
- property view¶
- class SaveFileNameField(prompt, ext='', default_name='', default=None)[source]¶
Bases:
object
SaveFileNameField
prompts the user to specify a file name to save. Result is stored in self.result as a string.- property default_name¶
- property ext¶
- property prompt¶
- property result¶
- class TextLineField(prompt: str, default: str | None = None)[source]¶
Bases:
object
TextLineField
Adds prompt for text string input. Result is stored in self.result as a string on completion.- property prompt¶
- property result¶
- get_address_input(prompt, title)[source]¶
get_address_input
prompts the user for an address with the given prompt and titleNote
This API function differently on the command-line vs the UI. In the UI a pop-up is used. On the command-line a simple text prompt is used.
- get_choice_input(prompt, title, choices)[source]¶
get_choice_input
prompts the user to select the one of the provided choicesNote
This API function differently on the command-line vs the UI. In the UI a pop-up is used. On the command-line a simple text prompt is used. The UI uses a combo box.
- Parameters:
- Return type:
integer array index of the selected option
- Example:
>>> get_choice_input("PROMPT>", "choices", ["Yes", "No", "Maybe"]) choices 1) Yes 2) No 3) Maybe PROMPT> 1 0L
- get_directory_name_input(prompt: str, default_name: str = '')[source]¶
get_directory_name_input
prompts the user for a directory name to save as, optionally providing a default_nameNote
This API function differently on the command-line vs the UI. In the UI a pop-up is used. On the command-line a simple text prompt is used. The UI uses the native window pop-up for file selection.
- get_form_input(fields, title)[source]¶
get_from_input
Prompts the user for a set of inputs specified infields
with given title. The fields parameter is a list which can contain the following types:FieldType
Description
str
an alias for LabelField
None
an alias for SeparatorField
LabelField
Text output
SeparatorField
Vertical spacing
TextLineField
Prompt for a string value
MultilineTextField
Prompt for multi-line string value
IntegerField
Prompt for an integer
AddressField
Prompt for an address
ChoiceField
Prompt for a choice from provided options
OpenFileNameField
Prompt for file to open
SaveFileNameField
Prompt for file to save to
DirectoryNameField
Prompt for directory name
This API is flexible and works both in the UI via a pop-up dialog and on the command-line.
Note
More complicated APIs should consider using the included pyside2 functionality in the binaryninjaui module. Returns true or false depending on whether the user submitted responses or cancelled the dialog.
- Parameters:
fields (list(str) or list(None) or list(LabelField) or list(SeparatorField) or list(TextLineField) or list(MultilineTextField) or list(IntegerField) or list(AddressField) or list(ChoiceField) or list(OpenFileNameField) or list(SaveFileNameField) or list(DirectoryNameField)) – A list containing these classes, strings or None
title (str) – The title of the pop-up dialog
- Return type:
- Example:
>>> int_f = IntegerField("Specify Integer") >>> tex_f = TextLineField("Specify name") >>> choice_f = ChoiceField("Options", ["Yes", "No", "Maybe"]) >>> get_form_input(["Get Data", None, int_f, tex_f, choice_f], "The options") Get Data <empty> Specify Integer 1337 Specify name Peter The options 1) Yes 2) No 3) Maybe Options 1 >>> True >>> print(tex_f.result, int_f.result, choice_f.result) Peter 1337 0
- get_int_input(prompt, title)[source]¶
get_int_input
prompts the user to input a integer with the given prompt and titleNote
This API function differently on the command-line vs the UI. In the UI a pop-up is used. On the command-line a simple text prompt is used.
- get_large_choice_input(prompt, title, choices)[source]¶
get_large_choice_input
prompts the user to select the one of the provided choices from a large poolNote
This API function differently on the command-line vs the UI. In the UI a pop-up is used. On the command-line a text prompt is used. The UI uses a filterable list of entries
- Parameters:
- Return type:
integer array index of the selected option
- Example:
>>> get_large_choice_input("Select Function", "Select a Function", [f.symbol.short_name for f in bv.functions])
- get_open_filename_input(prompt: str, ext: str = '') str | None [source]¶
get_open_filename_input
prompts the user for a file name to openNote
This API functions differently on the command-line vs the UI. In the UI a pop-up is used. On the command-line a simple text prompt is used. The UI uses the native window pop-up for file selection.
Multiple file selection groups can be included if separated by two semicolons. Multiple file wildcards may be specified by using a space within the parenthesis.
Also, a simple selector of *.extension by itself may also be used instead of specifying the description.
- get_save_filename_input(prompt: str, ext: str = '', default_name: str = '') str | None [source]¶
get_save_filename_input
prompts the user for a file name to save as, optionally providing a file extension and default_nameNote
This API function differently on the command-line vs the UI. In the UI a pop-up is used. On the command-line a simple text prompt is used. The UI uses the native window pop-up for file selection.
- get_text_line_input(prompt, title)[source]¶
get_text_line_input
prompts the user to input a string with the given prompt and titleNote
This API function differently on the command-line vs the UI. In the UI a pop-up is used. On the command-line a simple text prompt is used.
- run_progress_dialog(title: str, can_cancel: bool, task: Callable[[Callable[[int, int], bool]], None]) bool [source]¶
run_progress_dialog
runs a given task in a background thread, showing an updating progress bar which the user can cancel.- Parameters:
title (str) – Dialog title
can_cancel (bool) – If the task can be cancelled
task (Callable[[Callable[[int, int], bool]], None]) – Function to perform the task, taking as a parameter a function which should be called to report progress updates and check for cancellation. If the progress function returns false, the user has requested to cancel, and the task should handle this appropriately.
- Returns:
True if not cancelled
- Return type:
- show_graph_report(title, graph)[source]¶
show_graph_report
displays a flow graph in UI applications and nothing in command-line applications. This API doesn’t support clickable references into an existing BinaryView. Use theBinaryView.show_html_report
API if hyperlinking is needed.Note
This API function will have no effect outside the UI.
- show_html_report(title, contents, plaintext='')[source]¶
show_html_report
displays the HTML contents in UI applications and plaintext in command-line applications. This API doesn’t support hyperlinking into the BinaryView, use theBinaryView.show_html_report
API if hyperlinking is needed.
- show_markdown_report(title, contents, plaintext='')[source]¶
show_markdown_report
displays the markdown contents in UI applications and plaintext in command-line applications. This API doesn’t support hyperlinking into the BinaryView, use theBinaryView.show_markdown_report
API if hyperlinking is needed.Note
This API function differently on the command-line vs the UI. In the UI a pop-up is used. On the command-line a simple text prompt is used.
- show_message_box(title, text, buttons=MessageBoxButtonSet.OKButtonSet, icon=MessageBoxIcon.InformationIcon)[source]¶
show_message_box
Displays a configurable message box in the UI, or prompts on the console as appropriate- Parameters:
title (str) – Text title for the message box.
text (str) – Text for the main body of the message box.
buttons (MessageBoxButtonSet) – One of
MessageBoxButtonSet
icon (MessageBoxIcon) – One of
MessageBoxIcon
- Returns:
Which button was selected
- Return type:
- show_plain_text_report(title, contents)[source]¶
show_plain_text_report
displays contents to the user in the UI or on the command-lineNote
This API functions differently on the command-line vs the UI. In the UI, a pop-up is used. On the command-line, a simple text prompt is used.
- show_report_collection(title, reports)[source]¶
show_report_collection
displays multiple reports in UI applicationsNote
This API function will have no effect outside the UI.
- Parameters:
reports (ReportCollection) – Reports to display
- Return type:
None