#hex-editor #binary-file #tui #reverse-engineering #file-format #user-interface #binary-patching

bin+lib hex-patch

HexPatch is a binary patcher and editor with terminal user interface (TUI), it's capable of disassembling instructions and assembling patches. It supports a variety of architectures and file formats. Also, it can edit remote files via SSH

11 stable releases

new 1.9.1 Oct 23, 2024
1.9.0 Sep 6, 2024
1.8.0 Aug 18, 2024
1.7.2 Jul 19, 2024

#152 in Development tools

Download history 329/week @ 2024-07-08 177/week @ 2024-07-15 45/week @ 2024-07-22 154/week @ 2024-07-29 119/week @ 2024-08-05 89/week @ 2024-08-12 50/week @ 2024-08-19 167/week @ 2024-09-02 14/week @ 2024-09-09 29/week @ 2024-09-16 18/week @ 2024-09-23 14/week @ 2024-09-30 5/week @ 2024-10-07 11/week @ 2024-10-14 141/week @ 2024-10-21

172 downloads per month

MIT and GPL-2.0 licenses

4MB
10K SLoC

Contains (ELF exe/lib, 3MB) test/elf.bin, (Mach-o exe, 2.5MB) test/macho.bin, (DOS exe, 2MB) test/pe.bin

Logo HexPatch

Crate Badge CI Badge Deps.rs Badge License Badge

HexPatch is a binary patcher and editor with terminal user interface (TUI), it's capable of disassembling instructions and assembling patches. It supports a variety of architectures and file formats. Also, it can edit remote files via SSH.

Installation

Using cargo

If you already have the requirements installed, you only need to run the following command:

cargo install hex-patch

Requirements

Using your package manager

NetBSD

On NetBSD, a package is available from the official repositories. To install it, simply run:

pkgin install hexpatch

Arch Linux

On Arch Linux, a package is available from the official repositories:

pacman -S hexpatch

Build from source

If you prefer to build from source:

cd /usr/pkgsrc/devel/hexpatch
make install

SSH connection

In order to connect via SSH, you can use the following command:

hex-patch --ssh <user>@<host>[:<port>] [--password <password>] [additional arguments]

If you don't specify a password, the client must be set up with keypair authentication and you must have a key in your ~/.ssh directory.

Keys are searched in the following order:

  • id_rsa
  • id_ed25519
  • id_ecdsa
  • id_dsa

The first key found will be used.

Supported file formats and architectures

The following file formats are supported by default:

  • Coff
  • CoffBig
  • Elf32
  • Elf64
  • MachO32
  • MachO64
  • Pe32
  • Pe64
  • Xcoff32
  • Xcoff64

Other file formats can be added with plugins.

The following architectures are supported:

  • Aarch64
  • Aarch64_Ilp32
  • Arm
  • I386
  • X86_64
  • X86_64_X32
  • Mips
  • Mips64
  • PowerPc
  • PowerPc64
  • Riscv32
  • Riscv64
  • S390x
  • Sparc64

Settings

Read the settings documentation for more information.

Plugins

HexPatch supports plugins written in Lua. Plugins must be placed in the plugins directory in hex-patch's configuration directory. A different plugins directory can be specified with the --plugins flag.

You can find more information about the Plugin Lua API here.

Features

  • Help menu Help menu

  • Log Log

  • Text view Text view

  • Jump to address Jump to address Jump to a virtual address with v0x or to a file offset with 0x. You can also jump to symbols and sections.

  • Open file Open file

  • Run command Run command

  • Find text Find text

  • Find symbol Find symbol

  • Insert Text Insert text

  • Patch Patch

Known issues

  • Some key combinations may not work as expected, notably SHIFT + ENTER on VSCode terminal. Please refer to this issue for more information. Unfortunately, this behavior is out of my control.
  • If you try to write an invalid relative jump instruction with more than one register (e.g. jmp [rip+rax]) in X86 architectures the program will crash. This problem depends on the keystone-engine crate, and it's out of my control.

Special thanks

Thanks to Lorenzo Colombini for the instruction highlighting.

Dependencies

~103MB
~2M SLoC