unstrip
Python bindings for unstrip, which recovers function names, method signatures, types, interface dispatch tables and build metadata from stripped Go binaries.
ELF, Mach-O and PE; amd64, arm64 and 386, and the code of 32-bit arm, mips, ppc64 and riscv64 builds; Go 1.2 through 1.27 (types and itabs from Go 1.7).
The bindings call the same Rust code as the unstrip command, so they report what the CLI reports.
pip install unstrip
Wheels are built for CPython 3.9 and newer (one abi3 wheel per platform) on Linux x86_64 and aarch64 (manylinux), macOS arm64 and Windows x86_64. Other platforms build from the source distribution, which needs a Rust toolchain (1.85 or newer).
Use
unstrip.open(path) reads a binary, unstrip.parse(data) reads one from bytes.
The binary's methods return plain objects: frozen, compared by value, with a repr that lists their fields.
import unstrip
binary = unstrip.open("beacon")
print(binary)
info = binary.info()
print(info.go_version, info.goos, info.goarch, info.garble.verdict)
for f in binary.functions():
if f.name in ("main.(*Beacon).seal", "fmt.Sprintf"):
print(f"{f.entry:#x} {f.name}{f.signature} ({f.signature_source})")
<unstrip.Binary ELF amd64 go1.24.13>
go1.24.13 linux amd64 clean
0x4d7520 fmt.Sprintf(format string, a ...any) string (stdlib)
0x633800 main.(*Beacon).seal(_0 []uint8) ([]uint8, error) (reflection)
A method's signature comes from its func type in the binary, which records no parameter names (_0, _1).
A standard library function's comes from a per-release table built from the Go API snapshots Ghidra ships, with names; signature_release says which release.
Other free functions have none: the binary does not record their signatures.
PC lookup lists every frame at a PC, inlined ones first, the physical function last:
run = next(f for f in binary.functions() if f.name == "main.(*Beacon).Run")
for frame in binary.pc_location(run.entry + 0x40).frames:
print(frame.function, frame.line, "inlined" if frame.inlined else "physical")
os.Hostname 9 inlined
main.(*Beacon).Run 81 physical
Types carry their names as Go source writes them, struct fields with offsets and tags, and method tables; itabs give each (interface, concrete type) pair and the code its methods dispatch to:
beacon = next(t for t in binary.types() if t.name == "main.Beacon")
for field in beacon.fields:
print(f"+{field.offset:#04x} {field.name} {field.type} {field.tag}".rstrip())
for itab in binary.itabs():
if itab.interface == "main.Transport":
print(itab.concrete, [m.name for m in itab.methods])
+0x00 ID string json:"id"
+0x10 Interval time.Duration json:"interval"
+0x18 transports []main.Transport
+0x30 aead cipher.AEAD
+0x40 mu sync.Mutex
+0x48 sent int
*main.httpTransport ['Name', 'Send']
main.dnsTransport ['Name', 'Send']
strings() returns the string literals the code is proven to use, each with the instructions that use it (amd64, arm64, 386, 32-bit arm, mips, ppc64 and riscv64):
for literal in binary.strings():
if literal.text == "http://127.0.0.1:9/c":
print(literal)
Literal(addr=0x71b0d9, length=20, text='http://127.0.0.1:9/c', origin='literal', uses=[LiteralUse(pc=0x633b7b, function='main.main', function_entry=0x633a80, site='store')], headers=[])
origin(name) says where a function's code comes from, by the build info, as --own decides it: own (package main and the main module), dependency, stdlib, generated or undecided (a package the build info does not place, such as a garbled path). [f for f in binary.functions() if binary.origin(f.name) == "own"] is the program's own code.
garble() gives the garble verdict and the signals behind it, reflect_names() the table of hashed names to the original ones that garble keeps for reflection, and unstrip.diff(old, new) pairs the functions of two builds, two garble seeds of one program included:
old = unstrip.open("beacon-seed1")
new = unstrip.open("beacon-seed2")
print(old.garble().verdict, len(old.reflect_names()))
report = unstrip.diff(old, new)
print(report.old_total, report.identical, report.renamed, report.ambiguous_old)
print(next(p for p in report.pairings if p.kind == "renamed" and p.method == "code"))
garbled 981
5944 1518 3720 669
Pairing(kind='renamed', method='code', confidence='high', old_addr=0x46bca0, new_addr=0x46bca0, old_name='sync/atomic.J1ajpGx', new_name='sync/atomic.VrtRZg8q', old_reflect_name=None, new_reflect_name=None)
buildinfo() returns the module information go version -m prints, with settings as a dict in the order the build wrote them.
A file that does not read as a Go binary raises unstrip.UnstripError with the reason; a file that cannot be read raises the OSError the system gave:
try:
unstrip.parse(b"MZ" + bytes(62))
except unstrip.UnstripError as err:
print(err)
Go metadata does not decode: goblin: Malformed entity: PE header is malformed (signature 0x5a4d)
Every method reads its part of the binary on each call, so keep a result you need twice.
The reads that walk the whole binary release the GIL, so threads can read several binaries at once.
The package ships type hints (py.typed); the stub lists every class and field.
License
MIT or Apache-2.0, at your option. The standard library signature table is Apache-2.0 only, derived from the Go API snapshots in Ghidra; its NOTICE ships in the wheel.
Metadata
Release files for unstrip 2.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| unstrip-2.2.0.tar.gz | 916.1 kB | Without provenance | Details for unstrip-2.2.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| unstrip-2.2.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details for unstrip-2.2.0-cp39-abi3-win_amd64.whl |
| unstrip-2.2.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details for unstrip-2.2.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
| unstrip-2.2.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details for unstrip-2.2.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
| unstrip-2.2.0-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details for unstrip-2.2.0-cp39-abi3-macosx_11_0_arm64.whl |
Total release size: 5.3 MB
Release files / unstrip-2.2.0.tar.gz
| Download URL | unstrip-2.2.0.tar.gz |
|---|---|
| Size | 916.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
53e0ca4c315b58e3677394c128114394c0696b80e58a66d305dccf0a15716a4d
|
|
BLAKE2b-256 checksum How to use checksums |
f9f282ce6109806e7e08a83a8ec03e2446bb77be3cbb5910f6508f922871d5e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / unstrip-2.2.0-cp39-abi3-win_amd64.whl
| Download URL | unstrip-2.2.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1e3086e29913ffa216f057c6bf8f0ea915efc08701afd4da0242afd741cb8cff
|
|
BLAKE2b-256 checksum How to use checksums |
c0a423284c42115231eeefc9f36ad124310f645dd44d350aafe6e97e0395bfc1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / unstrip-2.2.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | unstrip-2.2.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
0387b6990818f01c06d7a03578ed3926beb0eea60a456c2b489d24f04ae6d81d
|
|
BLAKE2b-256 checksum How to use checksums |
a9eb7dacadd6a685b55ec580c4f8ab7e0fdc144561526ab483eb16bb2a1e3a35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / unstrip-2.2.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | unstrip-2.2.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
c88d59153fe95d98dd1392f45758441d5cc461307320c14048bbda3683802657
|
|
BLAKE2b-256 checksum How to use checksums |
6c0224dc4224780be85751dd49f208db0a4130a16f7b042724ed643a1d16acbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / unstrip-2.2.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | unstrip-2.2.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
1b00b3d54e5503aee4722014f971bfaa4573338293631e1d28f0bea523a665d2
|
|
BLAKE2b-256 checksum How to use checksums |
d3324c66716cce17f4d921263b7b48e78a844ffbbf268f27d3a7a7d8ee26e8e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for unstrip 2.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.