Skip to main content

Python wrapper around the Ghidra decompiler

Project description

flatline

PyPI Python Downloads Docs CI

Python wrapper around the Ghidra decompiler. Provides a stable, pip-installable interface for single-function decompilation with structured output -- no Ghidra installation required.

Named after Dixie Flatline from William Gibson's Neuromancer (1984) -- a dead hacker's ROM construct, a consciousness extracted from hardware. In the same spirit, flatline brings Ghidra's decompiler into library form for extracting meaningful structure from binaries.

Features

  • Single-function decompilation -- pass a memory image, base address, and function entry point; get back structured C output with diagnostics.
  • Multi-ISA -- x86 (32/64), ARM64, RISC-V 64, and MIPS32 are fixture-backed; all other Ghidra-supported architectures are available best-effort.
  • Enriched output -- opt-in pcode IR with use-def edges and a networkx.MultiDiGraph projection for data-flow analysis.
  • Packaged runtime data -- compiled Sleigh assets come from the companion ghidra-sleigh package. No vendored Ghidra tree at runtime.
  • Deterministic -- repeated decompiles of the same input produce structurally equivalent output.

Installation

pip install flatline

Pre-built wheels are published for Linux x86_64/aarch64, Windows x86_64, and macOS x86_64/arm64 (Python 3.13+). If no wheel matches your platform, pip falls back to a source build.

Build from source

Source builds require a C++20 compiler, Ninja, and zlib headers:

Platform Install command
Ubuntu/Debian sudo apt-get install g++ ninja-build zlib1g-dev
Fedora/RHEL sudo dnf install gcc-c++ ninja-build zlib-devel
Arch Linux sudo pacman -S gcc ninja zlib
macOS brew install ninja zlib (Xcode provides the C++ compiler)
Windows Visual Studio with C++ workload; pip install ninja; vcpkg install zlib:x64-windows
python -m venv .venv
source .venv/bin/activate
pip install .

The native C++ extension is built automatically when a compiler is found. The published wheels already include it. Without it the Python API is fully importable, but decompile calls return a configuration_error result. See the installation guide for native bridge build modes and troubleshooting.

Quick start

from flatline import DecompileRequest, decompile_function

result = decompile_function(DecompileRequest(
    memory_image=raw_bytes,
    base_address=0x400000,
    function_address=0x401000,
    language_id="x86:LE:64:default",
    compiler_spec="gcc",
))

print(result.c_code)

Runtime data is auto-discovered from ghidra-sleigh. Pass runtime_data_dir=... only when overriding the default root.

Flatline zero-fills decoder lookahead past the end of memory_image by default (tail_padding=b"\x00"), so exact function slices work without manual caller padding.

Enriched output

Request enriched=True to get the post-simplification pcode IR:

result = decompile_function(DecompileRequest(
    memory_image=raw_bytes,
    base_address=0x400000,
    function_address=0x401000,
    language_id="x86:LE:64:default",
    compiler_spec="gcc",
    enriched=True,
))

pcode = result.enriched.pcode
graph = pcode.to_graph()          # networkx.MultiDiGraph
op = pcode.get_pcode_op(op_id)    # O(1) lookup
vn = pcode.get_varnode(vn_id)     # O(1) lookup

See the API reference for the full enriched-output contract.

Flatline X-Ray

flatline-xray is a shipped interactive pcode viewer for caller-provided memory images:

pip install "flatline[xray]"     # adds optional capstone disassembly
flatline-xray --help

See the X-Ray docs for usage and tutorial.

Development

python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

tox                                          # tests + lint
tox -e lint                                  # lint only
tox -e py313,py314 -- -m unit                # unit tests only
tox -e py313,py314 -- -m requires_native     # native-dependent tests

Tox test envs build and install wheels, so the suite exercises the packaged artifact. Release and diagnostic helpers live under tools/ and are excluded from distribution artifacts.

Building the docs locally

pip install -e ".[docs]"
PYTHONPATH=src mkdocs serve        # http://127.0.0.1:8000

Full documentation is at https://patacca.github.io/flatline/.

Changelog

See CHANGELOG.md. Release policy and support tiers are documented in docs/release_notes.md.

Acknowledgments

This project was developed with the support of Quarkslab.

License

Apache-2.0. See LICENSE for the project license and NOTICE for redistribution-time attribution.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flatline-0.1.2.tar.gz (1.6 MB view details)

Uploaded Source

Built Distributions

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

flatline-0.1.2-cp314-cp314-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.14Windows x86-64

flatline-0.1.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

flatline-0.1.2-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (2.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

flatline-0.1.2-cp314-cp314-macosx_11_0_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.14macOS 11.0+ x86-64

flatline-0.1.2-cp314-cp314-macosx_11_0_arm64.whl (1.6 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

flatline-0.1.2-cp313-cp313-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.13Windows x86-64

flatline-0.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

flatline-0.1.2-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (2.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

flatline-0.1.2-cp313-cp313-macosx_11_0_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ x86-64

flatline-0.1.2-cp313-cp313-macosx_11_0_arm64.whl (1.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

File details

Details for the file flatline-0.1.2.tar.gz.

File metadata

  • Download URL: flatline-0.1.2.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flatline-0.1.2.tar.gz
Algorithm Hash digest
SHA256 431249904e7477a9ba1845873bce12da5abc6916fa28c43c30dd873a10e722f3
MD5 a2701575d626ab243ae0f4bfe5da488f
BLAKE2b-256 d796695914edaac0b65f6628001398f10da7f1342ae2b3cc9fceb4f86869031a

See more details on using hashes here.

Provenance

The following attestation bundles were made for flatline-0.1.2.tar.gz:

Publisher: release.yml on patacca/flatline

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flatline-0.1.2-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: flatline-0.1.2-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flatline-0.1.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 0a554cdc155d42ae106f9e989a5c2c16e91b707dbb2fdd7f0a066d29c085cd52
MD5 5e867e86908842f76d9224e999e990c6
BLAKE2b-256 63d9ed7b5addeee8b1ad046fcac1ff501d577b676c4bde92ac96228ee3e22262

See more details on using hashes here.

Provenance

The following attestation bundles were made for flatline-0.1.2-cp314-cp314-win_amd64.whl:

Publisher: release.yml on patacca/flatline

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flatline-0.1.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for flatline-0.1.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1384c110970dfbf7609df56914783b489113cb048d027e8f879aa4cd6478eb8b
MD5 c166d21e5fe2e080bb7cfcc425dfc931
BLAKE2b-256 2cf7cb74dfa88691ece86d68a2c30962c031af74f52b95b3dc3af8c441d38fd5

See more details on using hashes here.

Provenance

The following attestation bundles were made for flatline-0.1.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on patacca/flatline

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flatline-0.1.2-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for flatline-0.1.2-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 dfe86c0f05009c40c9e56119d53c8133ff9c7fb2de3b75ce40c04f6c591a7a62
MD5 1cfa731107ed964ca0f8a48bd9c21430
BLAKE2b-256 76bc28316fa8b5b6a46122fe9e3862b6480f5c48be732b4c7d05ce296193c6b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for flatline-0.1.2-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yml on patacca/flatline

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flatline-0.1.2-cp314-cp314-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for flatline-0.1.2-cp314-cp314-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 9a4035db7db371545a6665279eeace383dadf88405d7efd211e4660980acf916
MD5 4d1e914029961e04ed2eb7b5a3d6dbfd
BLAKE2b-256 5ef507fdf4501ed4822b095933b062ad315b57e07c1eb4ca916ca20893eb6c4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for flatline-0.1.2-cp314-cp314-macosx_11_0_x86_64.whl:

Publisher: release.yml on patacca/flatline

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flatline-0.1.2-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for flatline-0.1.2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ea07e235595f709c8cd3fe2daeebbf762dae76dc4e5ed0ead430e0eb3287b2b3
MD5 defc831b4c01b467734e888989969d06
BLAKE2b-256 ce695652754d27a8413faa22c09091d046e5471de95cca292412f813ce4e1cc5

See more details on using hashes here.

Provenance

The following attestation bundles were made for flatline-0.1.2-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: release.yml on patacca/flatline

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flatline-0.1.2-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: flatline-0.1.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flatline-0.1.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 158f3289023c472f4dc9eed946f80e404631605529c9ac678b08721e2b127609
MD5 99b5a8fb7cb2dc3270f882f8e77818d8
BLAKE2b-256 ed2d428f4c6d992c6c6893302f2f7b18362fdfc2ffb6b891b144a934b9d97410

See more details on using hashes here.

Provenance

The following attestation bundles were made for flatline-0.1.2-cp313-cp313-win_amd64.whl:

Publisher: release.yml on patacca/flatline

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flatline-0.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for flatline-0.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f1cb22dcb3c8f8960e3c80d1a381bca66e4a9a86988e1b71f82a68228bea2ff6
MD5 28dd5cb237765c336d038f47dabca35f
BLAKE2b-256 9c0227cadaf881dbe1bc99d3cabb0193810073bcb18cfe3908bdbce67f3e0a74

See more details on using hashes here.

Provenance

The following attestation bundles were made for flatline-0.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on patacca/flatline

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flatline-0.1.2-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for flatline-0.1.2-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fb7e5cea1d19f3b75a6f01bcd4eb203150c7547a9d435af1072d82ebccfd95d4
MD5 33aa3c5d7e865b07f7c4a5170a7e8904
BLAKE2b-256 4612ef9d47abe37050e0d5723d99b1ee119b88073b8e6a4c4eeab18e66ca7533

See more details on using hashes here.

Provenance

The following attestation bundles were made for flatline-0.1.2-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yml on patacca/flatline

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flatline-0.1.2-cp313-cp313-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for flatline-0.1.2-cp313-cp313-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 afa16f8ac3e1df2572e54a0a1708cc570f6d6934d1249f091b01898bcbc208c4
MD5 b5f3ed586ed5ffe767b1816b310e54ea
BLAKE2b-256 b141bcea6fd53efa8dcf310bb6ff5f64b20713a71b7052dcce1b58e6ec1d8ece

See more details on using hashes here.

Provenance

The following attestation bundles were made for flatline-0.1.2-cp313-cp313-macosx_11_0_x86_64.whl:

Publisher: release.yml on patacca/flatline

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flatline-0.1.2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for flatline-0.1.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 403cbfe8bf3861c4bd1baa11cbf64641cbd9a0c5d8fb367bfb76d43d4d54a9a4
MD5 6ab84cd58e08da8914f6660dc26447fc
BLAKE2b-256 d4c302fc64c604cffc93a3d59617805d857866a40195934e3d875e57051a2132

See more details on using hashes here.

Provenance

The following attestation bundles were made for flatline-0.1.2-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on patacca/flatline

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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