Your Only Decompiler API Lib - A generic API to script in and out of decompilers
Project description
LibBS
The decompiler API that works everywhere!
LibBS is an abstracted decompiler API that enables you to write plugins/scripts that work, with minimal edit, in every decompiler supported by LibBS. LibBS was originally designed to work with BinSync.
Install
pip install -e .
Usage
LibBS exposes all decompiler API through the abstract class DecompilerInterface. The DecompilerInterface
can be used in either the default mode, which assumes a GUI, or headless mode. In headless mode, the interface will
start a new process using a specified decompiler.
UI Mode (default)
To use the same script everywhere, use the convenience function DecompilerInterface.discover_interface(), which will
auto find the correct interface. Copy the below code into any supported decompiler and it should run without edit.
from libbs.api import DecompilerInterface
deci = DecompilerInterface.discover_interface()
for function in deci.functions:
if function.header.type == "void *":
function.header.type = "long long"
deci.functions[function.addr] = function
Headless Mode
To use headless mode you must specify a decompiler to use. You can get the traditional interface using the following:
from libbs.api import DecompilerInterface
deci = DecompilerInterface.discover_interface(force_decompiler="ida", headless=True)
Artifact Access Caveats
In designing the dictionaries that contain all Artifacts in a decompiler, we had a clash between ease-of-use and speed.
When accessing some artifacts like a Function, we must decompile the function. Decompiling is slow. Due to this issue
we slightly changed how these dictionaries work to fast accessing.
The only way to access a full artifact is to use the getitem interface of a dictionary. In practice this
looks like the following:
for func_addr, light_func in deci.functions.items():
full_function = deci.function[func_addr]
Notice, when using the items function the function is light, meaning it does not contain stack vars and other
info. This also means using keys, values, or list on an artifact dictionary will have the same affect.
TODO
G/S: Getters/Setters
- Add all decompilers to auto-detect interface
ALL
- Move hook-inits to inside the
Interfacecreation for all decompilers?- This could cause issues. What happens when this is done twice?
IDA
- Change Callbacks
- G/S Comments
Binja
- Change Callbacks
Ghidra
- Change Callbacks
- Get/Set Comments
angr
- Change Callbacks
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file libbs-0.6.9.tar.gz.
File metadata
- Download URL: libbs-0.6.9.tar.gz
- Upload date:
- Size: 88.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ee0883910dad894ee128dd7f1c859bdcef06dc229e55645a367ad90ac83874c
|
|
| MD5 |
b8c73f1100d2d56ffe00e6121c1e1684
|
|
| BLAKE2b-256 |
96172b434eab351293ec4be95722f9c3fafc1e337216f4186654d9c5fddf1f6a
|
File details
Details for the file libbs-0.6.9-py3-none-any.whl.
File metadata
- Download URL: libbs-0.6.9-py3-none-any.whl
- Upload date:
- Size: 105.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c711dd4226be4c577ffe29b0e7f17a373d944bd02e7dc94d0c7cf1cb715b4e69
|
|
| MD5 |
2355d8b6f5a84fddeacdee48fbc847b5
|
|
| BLAKE2b-256 |
a83ee4e86b93d6539e59f5cfe68e3a78a1b6ddd42406c390ce11c2c4d7b8cb00
|