Skip to main content

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, and is the backbone for all BinSync based plugins.

Install

pip install libbs

You can optionally also do libbs --install after to install generic plugins, but it's not required, since libbs files will be installed with plugins that use it.

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.

You can find various examples using LibBS in the examples folder. Examples that are plugins show off more of the complicated API that allows you to use an abstracted UI, artifacts, and more.

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

IDA

  • G/S Comments

Binja

  • Change Callbacks

Ghidra

  • Change Callbacks
  • Get/Set Comments

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

libbs-0.11.0.tar.gz (89.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

libbs-0.11.0-py3-none-any.whl (107.2 kB view details)

Uploaded Python 3

File details

Details for the file libbs-0.11.0.tar.gz.

File metadata

  • Download URL: libbs-0.11.0.tar.gz
  • Upload date:
  • Size: 89.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for libbs-0.11.0.tar.gz
Algorithm Hash digest
SHA256 683ffe06d860e6af8a6e7399807f96610daf1e64205f099168dc515eb18fb1cb
MD5 10588907b458647c69c1a77413135159
BLAKE2b-256 9de595dafd6e6c9bbdd935cee6e85f94044da4c5f272167b50b815f08ad16f73

See more details on using hashes here.

File details

Details for the file libbs-0.11.0-py3-none-any.whl.

File metadata

  • Download URL: libbs-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 107.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for libbs-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4669bd945a74ac5b5ffffaa0720148b1aaa094ea40329c4e670647896a449445
MD5 7bed0bf221501950051f9b694ad13f77
BLAKE2b-256 56cdb31a8117832270598a286af8ec0fd3ee6437e492658335e3a3aea3f3a260

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page