Skip to main content

cacadump

A terminal hex editor with binary templates.

  • gtcaca — a libcaca-based TUI toolkit — draws the interface.
  • libpcapng / pycapng and its POSA decoder language provide the parsing engine.

Binary structure is described declaratively in .posa files (not code); the POSA engine parses a buffer into a field tree, and that same tree drives both the coloured hex grid and the template pane.

 cacadump   photo.png   69 bytes   fmt:PNG                              F1 Help
 00000000  89 50 4E 47 0D 0A 1A 0A  00 00 00 0D 49 48 44 52 |.PNG........IHDR| │ Inspector @ 0x10
 00000010  00 00 00 04 00 00 00 04  08 06 00 00 00 A9 F1 9E |................| │ uint32   4
 00000020  7E 00 00 00 0C 49 44 41  54 78 9C 63 60 20 0D 00 |~....IDATx.c` ..| │ …
                                                                            │ Template: PNG
                                                                            │ PNG
                                                                            │   Signature: 8 bytes
                                                                            │   Chunks
                                                                            │     IHDR (13 bytes)
                                                                            │       Width: 4
                                                                            │       Color type: Truecolor+Alpha (6)
 0x10 (16)  HEX OVR                                                     PNG

Features

  • Hex + ASCII panes with a movable caret, insert/overwrite editing, undo/redo.
  • Binary templates via POSA: autodetects the format from the buffer's magic, dissects it, colours each byte by the field it belongs to, and shows the parsed structure in a live tree that follows the cursor.
  • Data inspector: the bytes at the cursor decoded as int8…int64 / uint / float32 / float64 (both byte orders), char and binary — all at once.
  • Goto offset, find (text or 0x.. hex) with find-next, selection anchor, bookmarks.
  • Ships decoders for PNG, GIF, BMP, GZIP, WAV and — because POSA is libpcapng's own decoder language — every network protocol libpcapng/carcal ships (DNS, HTTP, TLS, DHCP, SMB, …), usable on any selected buffer.

Install

pip install cacadump      # pulls in gtcaca and pycapng wheels
cacadump path/to/file

The .posa decoders live in the fileformat.posa submodule, so clone with --recurse-submodules (or run git submodule update --init in an existing checkout).

For local development against checkouts of gtcaca and libpcapng:

git clone --recurse-submodules https://github.com/stricaud/cacadump
python -m venv .venv
PKG_CONFIG_PATH=$(brew --prefix libcaca)/lib/pkgconfig \
  .venv/bin/pip install scikit-build-core pybind11 setuptools-scm
PKG_CONFIG_PATH=$(brew --prefix libcaca)/lib/pkgconfig \
  .venv/bin/pip install --no-build-isolation -e ../gtcaca -e ../libpcapng
.venv/bin/pip install -e .

Keys

arrows / PgUp / PgDn / Home / End move the cursor
TAB switch between the hex and ASCII panes
0-9 a-f (hex pane) / any char (ASCII pane) overwrite the byte under the cursor
INSERT toggle insert / overwrite
DELETE / BACKSPACE delete byte / delete left
m set / clear the selection anchor
b toggle a bookmark
F2 run the template (POSA autodetect)
F3 goto offset (0x.., or +N from cursor)
F4 / F5 find (text or 0x.. hex) / find next
F6 / F7 undo / redo
F8 toggle the sidebar
F9 / F10 open the menu bar (ESC leaves it)
Ctrl-S save (Ctrl-W also works, for terminals that swallow Ctrl-S as XOFF)
Ctrl-D / Ctrl-U decode the payload of a wrapped file / back out to the file bytes
Ctrl-X quit (confirms through a modal dialog if anything is unsaved)
F1 help

Everything on the menu bar is also a key, and vice versa — File, Edit, View, Template and Help route to the same commands. F10 is gtcaca's own menu binding; F9 is wired to the same thing because F10 is intercepted by some terminals.

Wrapped files

Some formats are a header around a compressed stream. A NoteWorthy score is six bytes then zlib, and NWC1_SCORE only matches what comes out of it — so cacadump opens such a file at its payload and the template just works. The title bar shows the layer stack ([1/1 file > NWC (zlib)]); Ctrl-U drops back to the bytes on disk, Ctrl-D goes in again, and --raw skips decoding entirely.

Decoding is automatic only when the outer bytes have no decoder of their own. A .gz keeps its gzip.posa view — inflating it silently would hide the very structure that decoder exists to show — so you descend into it with Ctrl-D.

Each layer is a separate buffer with its own offsets, cursor and undo history, and offsets are never mapped across layers: DEFLATE has no byte-to-byte correspondence between input and output, so "the compressed bytes behind this field" would be a fiction. Saving re-encodes edited payloads back through their containers; a layer you did not edit is written back exactly as it was read, so opening and saving a file you didn't change never rewrites it.

Writing a template

Templates are .posa files (see the src/cacadump/protos/ submodule and libpcapng's doc/posa.md). A decoder is declarative — types, enums, repeat, when/else, scope, bits, and a label/info line:

Object<main> PNG
    abbrev "png"
    col "PNG"
    required bytes<8> signature "Signature"
    repeat until end as chunk "Chunks"
        label "%s (%u bytes)" ctype, length
        required uint32 length "Length"
        required str<4>  ctype  "Type"
        when ctype == 0x49484452:            # "IHDR"
            required uint32 width "Width"
            required uint32 height "Height"
            required uint8  bit_depth "Bit depth"
            required uint8  color_type "Color type"
                Truecolor+Alpha = 6
        else:
            required bytes[length] data "Data"
        required uint32 crc hex "CRC"

Point CACADUMP_PROTOS_DIR at a directory of your own (or several, separated by :) and the format is understood on the next open — no code change. Decoders meant for everyone belong upstream in fileformat.posa rather than dropped into the submodule checkout, where they would be lost on the next git submodule update.

Notes / limitations

  • POSA is byte-order-per-type, so formats that switch endianness or word size on a runtime field (ELF/PE/Mach-O 32-vs-64) are only partially expressible today.
  • Editing operates on an in-memory buffer; very large files load fully into memory.

License

MIT.

Download files

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

Source Distribution

cacadump-0.0.1.tar.gz (33.2 kB view details)

Uploaded Source

Built Distribution

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

cacadump-0.0.1-py3-none-any.whl (32.3 kB view details)

Uploaded Python 3

File details

Details for the file cacadump-0.0.1.tar.gz.

File metadata

  • Download URL: cacadump-0.0.1.tar.gz
  • Upload date:
  • Size: 33.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cacadump-0.0.1.tar.gz
Algorithm Hash digest
SHA256 5d80c42b8d7711178e16c551fcbb2fac720310ba15290eca9b87e6dd5f4fdb5d
MD5 8b393567a76bed270bc38acf34def6be
BLAKE2b-256 4f6f3f86cd6524af767dfffdf105d824ce9ac669ca5c0aa75e512bc387f26ca4

See more details on using hashes here.

Provenance

The following attestation bundles were made for cacadump-0.0.1.tar.gz:

Publisher: release.yml on stricaud/cacadump

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

File details

Details for the file cacadump-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: cacadump-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 32.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cacadump-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3911bc739a9e37e9dccdeea2335528fe8101945f80578e1426bb6403d2ac69ce
MD5 c70e7fe247861c2aef67559d210abe3c
BLAKE2b-256 bd332d434c0cc423b0b1c2c991d112d1f88a5e8fdd7a942e3aececf59d0798e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for cacadump-0.0.1-py3-none-any.whl:

Publisher: release.yml on stricaud/cacadump

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