A from-scratch x86-64 disassembler and emulator-backed debugger - no capstone, no objdump, no ptrace. Ships the Rust binary as a console script, ruff-style.
Project description
gravedigger
A from-scratch x86-64 disassembler and emulator-backed debugger. No capstone, no objdump, no ptrace — it decodes machine code by hand and runs it in its own software CPU.
Most debuggers borrow a corpse: they attach to a live process through the OS
(ptrace, the Windows debug API) and lean on a library like capstone to read
the bytes. gravedigger digs its own grave. It decodes x86-64 from raw opcodes,
parses ELF and PE containers itself, and executes instructions in a from-scratch
emulator — so you can single-step, breakpoint and inspect any x86-64 binary,
offline, on any OS, with zero dependencies.
$ gravedigger info ./a.out
format : Pe
arch : X86_64
entry : 0x140073550
sections:
name addr size flags
.text 0000000140001000 476160 x
.rdata 0000000140076000 130048
.data 0000000140096000 512 w
What it does
- Disassembles x86-64 the hard way — legacy prefixes, REX, ModRM/SIB,
RIP-relative addressing, one- and two-byte (
0f) opcode maps — and prints clean Intel syntax. - Follows control flow. Recursive descent walks from the entry point and every function symbol through calls and jumps, so you get a real listing instead of a linear sweep that trips over data and padding.
- Loads ELF64 and PE32+ natively (and raw shellcode blobs at a chosen base).
- Runs the code. A hand-written CPU — 16 registers, RFLAGS with correct arithmetic/overflow/carry semantics, a segmented address space with a mapped stack — executes instructions one at a time. Calls push, rets pop, syscalls surface as stop events. No host process is ever touched.
- Debugs interactively. Breakpoints, step, continue, register/memory/stack inspection, live disassembly — all driven by the emulator.
Disassemble
$ gravedigger disasm ./a.out --entry main
main:
0000000140012110: 48 83 ec 28 sub rsp, 0x28
0000000140012114: 49 89 d0 mov r8, rdx
0000000140012117: 48 63 d1 movsxd rdx, ecx
000000014001211a: 48 8d 0d 8f ed ff ff lea rcx, [rip - 0x1271]
0000000140012121: 45 31 c9 xor r9d, r9d
0000000140012124: e8 97 17 00 00 call 0x1400138c0
Raw machine code works too:
$ gravedigger disasm shellcode.bin --raw --base 0x400000
Debug
$ gravedigger debug ./a.out --entry main
gravedigger debugger -- 'help' for commands, 'q' to quit
=> 0000000140073550: 48 83 ec 28 sub rsp, 0x28
(grave) s
=> 0000000140073554: e8 77 02 00 00 call 0x1400737d0
(grave) s
=> 00000001400737d6: 48 8b ec mov rbp, rsp ; stepped INTO the call
(grave) stack 3
stack (rsp = 00007fffffffeec0):
00007fffffffeec0: 0000000000000000
00007fffffffeec8: 0000000140073559 <- return address, one past the call
00007fffffffeed0: 0000000000000000
That return address on the stack isn't printed by an OS — gravedigger's CPU
pushed it when it executed the call.
| command | does |
|---|---|
s [n] |
step n instructions (Enter repeats) |
c |
continue to breakpoint / halt / top-level ret |
b <t> |
breakpoint at 0xADDR, decimal, or a symbol |
d <t> |
delete breakpoint |
r |
dump registers and flags |
x <t> [n] |
examine memory |
stack [n] |
dump the stack |
dis [n] |
disassemble from rip |
Build
$ cargo build --release
$ cargo test # 12 tests: golden decode vectors + end-to-end emulation
No dependencies. The whole thing is std and hand-rolled tables.
How it fits together
bytes ──▶ x86::decode ──▶ Insn ──┬──▶ x86::fmt ──▶ Intel text
└──▶ emu::exec ──▶ CPU state / stops
file ──▶ loader (elf/pe/raw) ──▶ Program ──▶ analysis (recursive descent)
──▶ emu (mapped memory + stack)
──▶ dbg (interactive REPL)
See docs/ARCHITECTURE.md for the full tour.
Limitations
v0.1 covers the integer/scalar subset a modern compiler actually emits: mov,
lea, the full arithmetic/logic set, mul/div, shifts, cmov/setcc, push/pop, call,
ret, leave, conditional and indirect branches, movzx/movsx/movsxd, syscall.
Not yet: SSE/AVX/x87, and cdqe/cqo assume 64-bit width. The decoder emits
(bad) for anything it doesn't know rather than guessing.
License
MIT. Dig responsibly.
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 Distributions
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 gravedigger-0.1.0.tar.gz.
File metadata
- Download URL: gravedigger-0.1.0.tar.gz
- Upload date:
- Size: 33.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d21830340677030c5f5c59bdbc9125e2a4219cff698233750e2741d5cae845d8
|
|
| MD5 |
17be0468229b3bb1241b495478744231
|
|
| BLAKE2b-256 |
b69ae49a0d8bce98e132cd2eacdf936d89f1d886d92bd8faf7957df2eb357f75
|
Provenance
The following attestation bundles were made for gravedigger-0.1.0.tar.gz:
Publisher:
pypi.yml on Makeph/gravedigger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gravedigger-0.1.0.tar.gz -
Subject digest:
d21830340677030c5f5c59bdbc9125e2a4219cff698233750e2741d5cae845d8 - Sigstore transparency entry: 2225966073
- Sigstore integration time:
-
Permalink:
Makeph/gravedigger@8e2187c7c4ccf90ec989307d75e6cde396830392 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Makeph
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@8e2187c7c4ccf90ec989307d75e6cde396830392 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gravedigger-0.1.0-py3-none-win_amd64.whl.
File metadata
- Download URL: gravedigger-0.1.0-py3-none-win_amd64.whl
- Upload date:
- Size: 140.8 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5d458b8a10194e88895917f64c675d5b7c6d15eb6051a420cb697907f2dc404
|
|
| MD5 |
4d39c6f08c4cec59a3a1e8d170bf2b65
|
|
| BLAKE2b-256 |
eb138e5b1ffdeb13bc91a30f7058cd194f95c197e30529a586f265285fbe689c
|
Provenance
The following attestation bundles were made for gravedigger-0.1.0-py3-none-win_amd64.whl:
Publisher:
pypi.yml on Makeph/gravedigger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gravedigger-0.1.0-py3-none-win_amd64.whl -
Subject digest:
b5d458b8a10194e88895917f64c675d5b7c6d15eb6051a420cb697907f2dc404 - Sigstore transparency entry: 2225967240
- Sigstore integration time:
-
Permalink:
Makeph/gravedigger@8e2187c7c4ccf90ec989307d75e6cde396830392 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Makeph
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@8e2187c7c4ccf90ec989307d75e6cde396830392 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gravedigger-0.1.0-py3-none-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: gravedigger-0.1.0-py3-none-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 235.1 kB
- Tags: Python 3, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfc470a654618e51960dfcbedfa75248e71e1b11adf07c32af11cd7557dd9c8b
|
|
| MD5 |
4630fc97d8a59826347e7a6489986184
|
|
| BLAKE2b-256 |
98f4d4241bb6bb910595397d302f204c83c17d6b68c6be30a70ed7849320471d
|
Provenance
The following attestation bundles were made for gravedigger-0.1.0-py3-none-manylinux_2_34_x86_64.whl:
Publisher:
pypi.yml on Makeph/gravedigger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gravedigger-0.1.0-py3-none-manylinux_2_34_x86_64.whl -
Subject digest:
cfc470a654618e51960dfcbedfa75248e71e1b11adf07c32af11cd7557dd9c8b - Sigstore transparency entry: 2225966724
- Sigstore integration time:
-
Permalink:
Makeph/gravedigger@8e2187c7c4ccf90ec989307d75e6cde396830392 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Makeph
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@8e2187c7c4ccf90ec989307d75e6cde396830392 -
Trigger Event:
push
-
Statement type:
File details
Details for the file gravedigger-0.1.0-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: gravedigger-0.1.0-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 217.0 kB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
707d166c7292e97bb6de78087df9edfc8c902c644a3c76303f5b578277f08c9c
|
|
| MD5 |
6be9a4213368fa9a089e75bc609b09f9
|
|
| BLAKE2b-256 |
52236f28e27d88076888caa4773b1916c7e595a5ee721087a6ce7c2a8adb84ba
|
Provenance
The following attestation bundles were made for gravedigger-0.1.0-py3-none-macosx_11_0_arm64.whl:
Publisher:
pypi.yml on Makeph/gravedigger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gravedigger-0.1.0-py3-none-macosx_11_0_arm64.whl -
Subject digest:
707d166c7292e97bb6de78087df9edfc8c902c644a3c76303f5b578277f08c9c - Sigstore transparency entry: 2225967763
- Sigstore integration time:
-
Permalink:
Makeph/gravedigger@8e2187c7c4ccf90ec989307d75e6cde396830392 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Makeph
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@8e2187c7c4ccf90ec989307d75e6cde396830392 -
Trigger Event:
push
-
Statement type: