These days, I have access to a Windows 10 laptop, as opposed to my usual set of tools. One feature of Windows 10 that I really like is Windows Subsystem for Linux, or WSL for short. In case you have not followed the developments, it is a way to run native Linux executables under Windows, without the need for a full blown virtual machine (again, more info on the link provided). WSL is under constant development and it looks like a promising technology.
If you have been doing software reverse engineering, chances are you have heard about Binary Ninja, a reversing platform (and if not, click on the link ASAP, you are missing out). Binary Ninja can run natively on Windows, OSX and Linux. Provided you have the (cheap!) professional version you can also run it in headless mode. The following post will show you how you can run Binary Ninja in both GUI and headless mode under WSL.
I decided to take advantage of some sales in MSFT Windows Shop so I am using Pengwin, as my WSL distribution, and X410 as my add-on X-Server, for a total cost of $20.00. In case that you do not want to spend any money (free as in beer) or prefer FOSS alternatives (free as in speech), this list will provide a lot of alternatives, but as always YMMV.
BinaryNinja comes as a zip file. Unzip it at a location of your choice, for the sake of discussion I will assume that it is $HOME. Attempting to run it as-is, will result in a error message, similar to the one below:
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: xcb.  217 abort (core dumped) ./binaryninja/binaryninja
retry running and voila! You have GUI Binary Ninja running.
Attempting to run Binary Ninja in headless mode, will give the following error:
ModuleNotFoundError: No module named 'binaryninja'
[EDIT] The canonical solution to this is to go to your Binary Ninja install directory and run the
scripts/install_api.py Python script. By doing this, a .pth file is added. Solution courtesy of Binary Ninja Slack (which is a great community to join).
one other solution to this is to set PYTHONPATH, if not set already or expand it if set. Edit your login script’s rc file and add the following one liner that takes care of both cases (adjust for your BinaryNinja installation directory):
[[ ! -z "$PYTHONPATH" ]] && export PYTHONPATH=$PYTHONPATH:$HOME/binaryninja/python || export PYTHONPATH=$HOME/binaryninja/python
Running one of the example programs should work now.
Personally, I made the transition to Python3 (and if you need some reasons, have a look here). BinaryNinja by default uses a Python2 provider – to change this to a Python3 provider, as provided by Pengwin, open advanced settings and select:
These are the basic steps for my BinaryNinja/WSL setup. If something is missing, feel free to drop a comment or a line anytime and I will update the post accordingly. Happy reversing!