Binary Ninja Python API Reference¶
Welcome to the Binary Ninja API documentation. The below methods are available from the root of the binaryninja package, but most of the API is organized into the modules shown in the left side-bar.
You can also scroll to the end to view a class list of all available classes.
The search bar on the side works both online and offline.
- bundled_plugin_path() Optional[str] [source]¶
bundled_plugin_path
returns a string containing the current plugin path inside the install path- Returns:
current bundled plugin path
- Return type:
str, or None on failure
- connect_pycharm_debugger(port=5678)[source]¶
Connect to PyCharm (Professional Edition) for debugging.
Note
See https://docs.binary.ninja/dev/plugins.html#remote-debugging-with-intellij-pycharm for step-by-step instructions on how to set up Python debugging.
- Parameters:
port – Port number for connecting to the debugger.
- connect_vscode_debugger(port=5678)[source]¶
Connect to Visual Studio Code for debugging. This function blocks until the debugger is connected! Not recommended for use in startup.py
Note
See https://docs.binary.ninja/dev/plugins.html#remote-debugging-with-vscode for step-by-step instructions on how to set up Python debugging.
- Parameters:
port – Port number for connecting to the debugger.
- core_build_id() int [source]¶
core_build_id
returns a integer containing the current build id- Returns:
current build id
- Return type:
- core_expires() struct_time [source]¶
License Expiration
- Return type:
- core_serial() Optional[str] [source]¶
core_serial
returns a string containing the current serial number- Returns:
current serial
- Return type:
str, or None on failure
- core_set_license(licenseData: str) None [source]¶
core_set_license
is used to initialize the core with a license file that doesn’t necessarily reside on a file system. This is especially useful for headless environments such as docker where loading the license file via an environment variable allows for greater security of the license file itself.- Parameters:
licenseData (str) – string containing the full contents of a license file
- Return type:
None
- Example:
>>> import os >>> core_set_license(os.environ['BNLICENSE']) #Do this before creating any BinaryViews >>> with load("/bin/ls") as bv: ... print(len(list(bv.functions))) 128
- core_ui_enabled() bool [source]¶
Indicates that a UI exists and the UI has invoked BNInitUI
- Return type:
- core_version() Optional[str] [source]¶
core_version
returns a string containing the current version- Returns:
current version
- Return type:
str, or None on failure
- core_version_info() CoreVersionInfo [source]¶
core_version_info
returns a CoreVersionInfo containing the current version information- Returns:
current version information
- Return type:
- disable_default_log() None [source]¶
Disable default logging in headless mode for the current session. By default, logging in headless operation is controlled by the ‘python.log.minLevel’ settings.
- Return type:
None
- get_install_directory()[source]¶
get_install_directory
returns a string pointing to the installed binary currently runningWarning
ONLY for use within the Binary Ninja UI, behavior is undefined and unreliable if run headlessly
- load(*args, **kwargs) BinaryView [source]¶
Opens a BinaryView object.
- Parameters:
source (Union[str, bytes, bytearray, 'databuffer.DataBuffer', 'os.PathLike']) – a file or byte stream to load into a virtual memory space
update_analysis (bool) – whether or not to run
update_analysis_and_wait
after opening aBinaryView
, defaults toTrue
progress_func (callback) – optional function to be called with the current progress and total count
options (dict) – a dictionary in the form {setting identifier string : object value}
- Returns:
returns a
BinaryView
object for the given filename- Return type:
BinaryView
- Raises:
Exception – When a BinaryView could not be created
Note
The progress_func callback must return True to continue the load operation, False will abort the load operation.
- Example:
>>> from binaryninja import * >>> with load("/bin/ls") as bv: ... print(len(list(bv.functions))) ... 134
>>> with load(bytes.fromhex('5054ebfe'), options={'loader.architecture' : 'x86'}) as bv: ... print(len(list(bv.functions))) ... 1
- Return type:
- open_view(*args, **kwargs) BinaryView [source]¶
Deprecated since version 3.5.4378: Use load instead
- Return type:
- shutdown()[source]¶
shutdown
cleanly shuts down the core, stopping all workers and closing all log files.
- user_directory() Optional[str] [source]¶
user_directory
returns a string containing the path to the user directory- Returns:
current user path
- Return type:
str, or None on failure
- user_plugin_path() Optional[str] [source]¶
user_plugin_path
returns a string containing the current plugin path inside the user directory- Returns:
current user plugin path
- Return type:
str, or None on failure
Full Class List¶
- architecture
- basicblock
- binaryview
- bncompleter
- callingconvention
- commonil
- component
- database
- databuffer
- datarender
- debugger
- debuginfo
- decorators
- demangle
- deprecation
- downloadprovider
- enums
- fileaccessor
- filemetadata
- flowgraph
- function
- functionrecognizer
- highlevelil
- highlight
- interaction
- lineardisassembly
- log
- lowlevelil
- mainthread
- mediumlevelil
- metadata
- platform
- plugin
- pluginmanager
- scriptingprovider
- secretsprovider
- settings
- transform
- typelibrary
- typeparser
- typeprinter
- types
- update
- variable
- websocketprovider
- workflow