Skip to main content

bindiffscript

Fancy diff tool for reverse engineering binary files using a scripted approach.

Most important difference to most other binary diff tools is the ability to add artificial insertions (padding) in order to align as similar parts of compared files as possible. Also, instead of modifying dozens of command line arguments you write a YAML based script which describes how you compare the provided files and how to view the content.

bindiffscript screenshot

This screenshot is the result of the following diff-script:

#!/usr/bin/env bindiffscript

width: 8
context: 2
colors: ["green", "red bold"]
format: "%d-%x-%a"
files:
    - path: ${here}/00reverse-1-init.xy
    - path: ${here}/00reverse-2-metro-off.xy
      padding:
      - [10, 4, 0]
      - [4221, 13, 0]

Install and use

You can either install bindiffscript via pipx

# have pipx installed first
pipx install bindiffscript
bindiffscript ...

.. simply run it via uvx provided by the uv package

# have uv installed first
uvx bindiffscript ...

.. or checkout the project and run it via uv run

# have git and uv installed first
git clone https://github.com/frans-fuerst/bindiffscript.git
cd bindiffscript
uv run bindiffscript ...

With all approaches you get an entry point bindiffscript with the following syntax:

bindiffscript [<opts>..] <FILE>*

Since <FILE> can be a YAML file containing options and files to diff, you can set a shebang to bindiffscript and make it executable:

#!/usr/bin/env bindiffscript
files:
    - path: path/to/file1.txt
    - path: path/to/file2.txt

.. which is the same as running bindiffscript example.yaml.

See the examples folder for syntax and inspiration!

Contribution

Initialize

git clone https://github.com/frans-fuerst/bindiffscript.git
cd bindiffscript
uv run pre-commit install

Manually run checks and fixes

# run all checks which would be executed on commit, but on unstaged stuff, too
uv run pre-commit run --hook-stage pre-commit --all-files

# run all type checking (mypy) on current (unstaged) state
uv run pre-commit run check-python-typing --all-files
uv run pre-commit run check-python-linting --all-files
uv run pre-commit run check-python-format --all-files
uv run pre-commit run check-python-isort --all-files
uv run pre-commit run check-python-unittest --all-files
uv run pre-commit run check-python-doctest --all-files
uv run pre-commit run check-yaml-linting --all-files

# these will modify the source code by applying formatting and linter rules
uv run pre-commit run fix-python-linting --hook-stage manual --all-files
uv run pre-commit run fix-python-format --hook-stage manual --all-files
uv run pre-commit run fix-python-isort --hook-stage manual --all-files

implement -> uv run pytest -> commit -> repeat

Publish to pypi.org

uv version --bump <patch|minor|major>
uv build
# manual tests
git push
uv publish --token <TOKEN>

Wishlist

  • Readme
  • Make width configurable via width attribute or command line option
  • Allow to specify padding value
  • Clip long files via head
  • Skip identical lines (i.e. context around differring lines)
  • Show padding differently
  • Configure cell format
  • Show some sort of line number
  • Update on change
  • Auto-generate padding (through diff algorithms)
  • Show multiple files
  • Show hex/text side by side
  • Highlight special/magic content
  • Textual interface with mouse hover and scrolling
  • Padding: set to fixed position
  • Padding: insert arbitrary data
  • Padding: length from macro
  • Annotations
  • Bash completion

External Sources

Metadata

Release files for bindiffscript 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bindiffscript 0.3.0
File Size Uploaded Provenance
bindiffscript-0.3.0.tar.gz 168.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for bindiffscript 0.3.0
File Interpreter ABI Platform
bindiffscript-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 175.3 kB

Release files / bindiffscript-0.3.0.tar.gz

Download URL bindiffscript-0.3.0.tar.gz
Size 168.6 kB
Tags Source
SHA-256 checksum
How to use checksums
04373ed27269e165aef8bf406b41aca2315b50cf6304f36658b5a66098aee25e
BLAKE2b-256 checksum
How to use checksums
8c8bc72e21a8ec8c76a9f48d0908d6abe9c78db1e30ff61b00501eb9b87d8512
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.11

Release files / bindiffscript-0.3.0-py3-none-any.whl

Download URL bindiffscript-0.3.0-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
098d7a139c964f91fd7015fd6856041681276b2f0e2430d82dca6d9e4ed9306c
BLAKE2b-256 checksum
How to use checksums
5b64ec4b0ddbeccdc587e48e1594b6aae1d4c812f9eb7bb8b0c7acf9773e5b07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.11

Security for bindiffscript 0.3.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page