{"id":50926179,"url":"https://github.com/binsync/declib","last_synced_at":"2026-06-16T23:04:11.449Z","repository":{"id":153766248,"uuid":"630617902","full_name":"binsync/declib","owner":"binsync","description":"A library for writing plugins in any decompiler: includes API lifting, common data formatting, and GUI abstraction!","archived":false,"fork":false,"pushed_at":"2026-06-07T18:27:35.000Z","size":1110,"stargazers_count":177,"open_issues_count":19,"forks_count":23,"subscribers_count":5,"default_branch":"main","last_synced_at":"2026-06-11T19:10:43.165Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/binsync.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-04-20T19:13:21.000Z","updated_at":"2026-06-11T07:24:24.000Z","dependencies_parsed_at":"2023-05-07T05:47:13.906Z","dependency_job_id":"6221b2a5-6981-4e96-88ad-70d512f1072d","html_url":"https://github.com/binsync/declib","commit_stats":null,"previous_names":["binsync/libbs","binsync/yodalib","binsync/declib"],"tags_count":146,"template":false,"template_full_name":null,"purl":"pkg:github/binsync/declib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binsync%2Fdeclib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binsync%2Fdeclib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binsync%2Fdeclib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binsync%2Fdeclib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binsync","download_url":"https://codeload.github.com/binsync/declib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binsync%2Fdeclib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34426759,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-16T23:04:10.658Z","updated_at":"2026-06-16T23:04:11.443Z","avatar_url":"https://github.com/binsync.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DecLib\nThe decompiler API that works everywhere!\n\nDecLib is an abstracted decompiler API that enables you to write plugins/scripts that work, with minimal edit, \nin every decompiler supported by DecLib. DecLib was originally designed to work with [BinSync](https://binsync.net), and is the backbone\nfor all BinSync based plugins.\nAs an example, with the same script, you can [redefine the types of function variables with custom structs](./examples/struct_and_variable_use.py), all in less\nthan 30 lines, in any supported decompilers.\n\n## Install\n```bash\npip install declib\n```\n\nThe minimum Python version is **3.10**.\n\n## Supported Decompilers\n- IDA Pro: **\u003e= 8.4** (if you have an older version, use `v1.26.0`)\n- Binary Ninja: **\u003e= 2.4**\n- angr-management: **\u003e= 9.0**\n- Ghidra: **\u003e= 12.0** (started in PyGhidra mode)\n\n## Usage\nDecLib exposes all decompiler API through the abstract class `DecompilerInterface`. The `DecompilerInterface` \ncan be used in either the default mode, which assumes a GUI, or `headless` mode. In `headless` mode, the interface will \nstart a new process using a specified decompiler.\n\nYou can find various examples using DecLib in the [examples](./examples) folder. Examples that are plugins show off\nmore of the complicated API that allows you to use an abstracted UI, artifacts, and more.\n\n### Agent CLI\n\nIf you want a simplified command line interface (especially well-suited for LLMs), see the\n[decompiler CLI guide](./docs/decompiler_cli.md).\n\n```\ndecompiler load /path/to/binary --backend ida\ndecompiler decompile main --id 1234\n```\n\n### UI Mode (default)\nTo use the same script everywhere, use the convenience function `DecompilerInterface.discover_interface()`, which will\nauto find the correct interface. Copy the below code into any supported decompiler and it should run without edit.\n\n```python\nfrom declib.api import DecompilerInterface\n\ndeci = DecompilerInterface.discover()\nfor addr in deci.functions:\n    function = deci.functions[addr]\n    if function.header.type == \"void\":\n        function.header.type = \"int\"\n        deci.functions[function.addr] = function\n```\n\nNote that for Ghidra in UI mode you must first start it in PyGhidra mode. You can do this by going to your install dir\nand running `./support/pyghidraRun`.\n\n### Headless Mode \nTo use headless mode you must specify a decompiler to use. You can get the traditional interface using the following:\n\n```python \nfrom declib.api import DecompilerInterface\n\ndeci = DecompilerInterface.discover(force_decompiler=\"ghidra\", headless=True)\n```\n\nIn the case of Ghidra, you must have the environment variable `GHIDRA_INSTALL_DIR` set to the path of the Ghidra \ninstallation (the place the `ghidraRun` script is located).\n\n### Artifact Access Caveats\nIn designing the dictionaries that contain all Artifacts in a decompiler, we had a clash between ease-of-use and speed. \nWhen accessing some artifacts like a `Function`, we must decompile the function. Decompiling is slow. Due to this issue\nwe slightly changed how these dictionaries work to fast accessing. \n\nThe only way to access a **full** artifact is to use the `getitem` interface of a dictionary. In practice this \nlooks like the following:\n```python\nfor func_addr, light_func in deci.functions.items():\n    full_function = deci.function[func_addr]\n```\n\nNotice, when using the `items` function the function is `light`, meaning it does not contain stack vars and other \ninfo. This also means using `keys`, `values`, or `list` on an artifact dictionary will have the same affect. \n\n### Serializing Artifacts\nAll artifacts are serializable to the TOML and JSON formats. Serialization is done like so:\n```python\nfrom declib.artifacts import Function\nimport json\n\nmy_func = Function(name=\"my_func\", addr=0x4000, size=0x10)\njson_str = my_func.dumps(fmt=\"json\")\nloaded_dict = json.loads(json_str) # now loadable through normal JSON parsing\nloaded_func = Function.loads(json_str, fmt=\"json\")\n```\n\n## Sponsors\nBinSync and its associated projects would not be possible without sponsorship.\nIn no particular order, we'd like to thank all the organizations that have previously or are currently sponsoring\none of the many BinSync projects.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/binsync/binsync/blob/main/assets/images/sponsors/nsf.png?raw=true\" alt=\"NSF\" style=\"height: 100px; display: inline-block; vertical-align: middle; margin-right: 40px;\"\u003e\n    \u003cbr\u003e\n    \u003cimg src=\"https://github.com/binsync/binsync/blob/main/assets/images/sponsors/darpa.png?raw=true\" alt=\"DARPA\" style=\"height: 70px; display: inline-block; vertical-align: middle; margin-right: 40px;\"\u003e\n    \u003cbr\u003e\n    \u003cimg src=\"https://github.com/binsync/binsync/blob/main/assets/images/sponsors/arpah.svg?raw=true\" alt=\"ARPA-H\" style=\"height: 50px; display: inline-block; vertical-align: middle; margin-right: 40px;\"\u003e\n    \u003cbr\u003e\n    \u003cimg src=\"https://github.com/binsync/binsync/blob/main/assets/images/sponsors/reveng_ai.svg?raw=true\" alt=\"RevEng AI\" style=\"height: 50px; display: inline-block; vertical-align: middle;\"\u003e\n\u003c/p\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinsync%2Fdeclib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinsync%2Fdeclib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinsync%2Fdeclib/lists"}