Skip to content

Commit

Permalink
plugins.md: review and editing for 3.2 complete
Browse files Browse the repository at this point in the history
  • Loading branch information
galenbwill committed Oct 24, 2022
1 parent 2810a47 commit 5063425
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions docs/guide/plugins.md
@@ -1,6 +1,6 @@
# Using Plugins

The most common Binary Ninja plugins are Python which we are covering here. That said, there are some C++ plugins which must be built for the appropriate native architecture and will usually include build instructions for each platform. Several [C++ examples](https://github.com/Vector35/binaryninja-api/tree/dev/examples) are included in the API repository, and the [binexport](https://github.com/google/binexport) utility (used with [bindiff](https://www.zynamics.com/bindiff.html)) is also a native plugin that must be built and installed manually.
The most common Binary Ninja plugins are written in Python which we are covering here. That said, there are some C++ plugins which must be built for the appropriate native architecture and will usually include build instructions for each platform. Several [C++ examples](https://github.com/Vector35/binaryninja-api/tree/dev/examples) are included in the API repository, and the [binexport](https://github.com/google/binexport) utility (used with [bindiff](https://www.zynamics.com/bindiff.html)) is also a native plugin that must be built and installed manually. Finally, there is preliminary support for [Rust plugins](https://github.com/Vector35/binaryninja-api/tree/dev/rust), but the Rust API is still in the early stages of development, and should be considered a moving target, so proceed with caution and develop at your own risk.

Plugins are loaded from the user's plugin folder:

Expand All @@ -14,15 +14,14 @@ Note that plugins installed via the [PluginManager API](https://api.binary.ninja

![Plugin Manager >](../img/plugin-manager.png "Plugin Manager")

Plugins can now be installed directly via the GUI from Binary Ninja. You can launch the plugin manager via any of the following methods:
Plugins can be installed directly via the GUI from Binary Ninja. You can launch the plugin manager via any of the following methods:

- (Linux/Windows) `[CTRL-SHIFT-M]`
- (macOS) `[CMD-SHIFT-M]`

Or:

- (Linux/Windows) `Edit` / `Preferences` / `Manage Plugins`
- (macOS) `Binary Ninja` / `Preferences` / `Manage Plugins`
- `Plugins` / `Manage Plugins`

Or:

Expand All @@ -33,7 +32,7 @@ Note that some plugins may show `Force Install` instead of the normal `Install`

### Plugin Manager Searching

The plugin manager also supports a number of helpful search keywords to filter through the list of plugins as it continues to grow:
In addition to finding plugins by name or description content, the search box in the plugin manager also supports a number of helpful search keywords to filter through the list of plugins as it continues to grow:

- `@installed` to only show installed plugins
- `@enabled` to only show enabled plugins
Expand All @@ -49,21 +48,21 @@ The following plugin categories are also searchable:

## Manual installation

You can manually install a plugin either by adding a folder which contains it (the plugin folder must contain an `__init__.py` at the top of the folder, or a python file can be included directly in the plugin folder--though this is not recommended).
You can manually install a plugin either by adding a folder which contains it (the plugin folder must contain an `__init__.py` at the top of the folder, or a python file can be included directly in the plugin folder -- though this is not recommended).

Note, if manually cloning the [api repository](https://github.com/Vector35/binaryninja-api), make sure to:

``` text
git submodule update --init --recursive
```

after cloning or else the submodules will not actually be downloaded.
after cloning or else the necessary submodules will not actually be downloaded.

### Installing via the API

Binary Ninja now offers a [PluginManager API](https://api.binary.ninja/binaryninja.pluginmanager-module.html) which can simplify the process of finding and installing plugins. From the console:
Binary Ninja includes a [PluginManager API](https://api.binary.ninja/binaryninja.pluginmanager-module.html) which can simplify the process of finding and installing plugins. From the console:

``` text
``` python
>>> mgr = RepositoryManager()
>>> dir(mgr)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'add_repository', 'check_for_updates', 'default_repository', 'handle', 'plugins', 'repositories']
Expand All @@ -82,13 +81,13 @@ False
True
```

Then just restart and your plugin will be loaded.
Then just restart and the newly-enabled plugin will be loaded.

### Installing Prerequisites

Binary Ninja can now automatically install pip requirements for python plugins when the plugin was installed using the plugin manager. If the plugin author has included a `requirements.txt` file, the plugin manager will automatically install those dependencies.
Binary Ninja can automatically install pip requirements for python plugins installed using the plugin manager. If the plugin author has included a `requirements.txt` file, the plugin manager will automatically install those dependencies.

Because Windows and macOS ship with an embedded version of Python, if you want to install plugins inside that Python, we recommend instead installing an official [python.org](https://www.python.org/downloads/windows/) (NOTE: ensure you do not accidentally install a 32-bit build) version, or a [homebrew](https://docs.brew.sh/Homebrew-and-Python) Python 3.x build.
Binary Ninja ship with an embedded version of Python on Windows and macOS. Instead of installing pip plugins inside that Python, we recommend installing an official version from [python.org](https://www.python.org/downloads/windows/) (NOTE: ensure you do not accidentally install a 32-bit build) or a [homebrew](https://docs.brew.sh/Homebrew-and-Python) Python 3.x build. Binary Ninja currently requires a version of Python 3.7 or greater, though 3.10 or newer is preferred (and may be required by some plugins).

Then you can adjust your [python.interpreter setting](settings.md#python.interpreter) to point to the appropriate install location. Note that the file being pointed to should be a `.dll` or `.dylib` though homebrew will often install libraries without any extension. For example:

Expand All @@ -99,15 +98,15 @@ $ file /usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3

### Troubleshooting

Troubleshooting many Binary Ninja problems is enhanced by enabling debug logs and logging the output to a file. Just launch Binary Ninja with:
When troubleshooting Binary Ninja problems, it may help to enable debug logging as well as logging the output to a file. Just launch Binary Ninja with:

``` text
/Applications/Binary\ Ninja.app/Contents/macOS/binaryninja -d -l /tmp/bnlog.txt
```

And check `/tmp/bnlog.txt` when you're done.

Additionally, running a python plugin with an environment variable of `BN_DISABLE_USER_PLUGINS` will prevent the API from initializing user-plugins which is helpful for identifying when a plugin is causing problems. Furthermore, by setting `BN_USER_DIRECTORY` you can override your 'user' directory where all your settings and plugins are loaded.
Additionally, running a python plugin with an environment variable of `BN_DISABLE_USER_PLUGINS` will prevent the API from initializing user-plugins. This is helpful for identifying when a plugin is causing problems. Furthermore, by setting `BN_USER_DIRECTORY` you can override your 'user' directory where all your settings and plugins are loaded.

## Writing Plugins

Expand Down

0 comments on commit 5063425

Please sign in to comment.