Skip to main content

XML-based binary patching tool with verification support

Project description

XPatch - XML-Based Binary Patching Tool

XPatch is a command-line tool that lets you apply binary patches to files using XML patch definitions. It can patch files, undo those changes, and check file integrity with MD5 checksums

Features

XML Patch Definitions : Define binary patches in XML for precise file modifications.
Dry Run Mode : Check if patches work before applying them.
Unpatch Support : Revert applied patches when needed.
MD5 Verification : Ensure file integrity before and after patching.


Usage

Basic Patching

xpatch PATCH_FILE.xml TARGET_FILE [OPTIONS]

Options

Flag Description
-n, --dry-run Test patch without modifying the file
-u Unpatch (revert changes) instead of patching
-v Verbose output (show detailed logs)
-m Verify MD5 checksum before patching

Patch XML Format

Example patch file (example.xml):

<patch name="example_patch" md5sum="d41d8cd98f00b204e9800998ecf8427e">
  <alter id="patch1" start="0x100" length="16">
    <from encoding="hex">48656c6c6f20576f726c6421</from> <!-- "Hello World!" -->
    <to encoding="hex">476f6f646279652021</to>         <!-- "Goodbye !" -->
  </alter>
</patch>

XML Structure

  • <patch> (Root element)
    • name: Patch identifier (optional)
    • md5sum: Expected MD5 of the target file (optional, used with -m)
  • <alter> (Patch operation)
    • id: Unique identifier for the patch
    • start: Byte offset where the patch starts (hex or decimal)
    • length: Number of bytes to replace (optional, defaults to <from> length)
  • <from> (Original data)
    • encoding="hex" (default) or encoding="text"
  • <to> (New data)
    • Must be ≤ length of <from>

Examples

1. Apply a Patch

xpatch example.xml target.bin -v -m
  • Verifies target.bin matches the expected MD5 (md5sum in XML).
  • Applies changes defined in example.xml.
  • Logs verbose output.

2. Dry Run (Test Patch Without Applying)

xpatch example.xml target.bin -n
  • Checks if the patch is applicable without modifying the file.

3. Unpatch (Revert Changes)

xpatch example.xml target.bin -u
  • Reverts the changes made by example.xml.

XPatch : The flexible binary patching tool. 🔧🔗

Project details


Download files

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

Source Distribution

xpatch-1.2.0.tar.gz (46.2 kB view details)

Uploaded Source

Built Distribution

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

xpatch-1.2.0-py3-none-any.whl (31.8 kB view details)

Uploaded Python 3

File details

Details for the file xpatch-1.2.0.tar.gz.

File metadata

  • Download URL: xpatch-1.2.0.tar.gz
  • Upload date:
  • Size: 46.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for xpatch-1.2.0.tar.gz
Algorithm Hash digest
SHA256 1f09c9eaf5e4680276ca2be95018b7a0ad15f6c0dbb46b23602e17868922f7cb
MD5 4d9de634950dd389088ee2f0e5d49a81
BLAKE2b-256 5b07cab4dfb09d1b6eea51dc632a8f1e851e809425c5a8058dbec6fffa376a7f

See more details on using hashes here.

File details

Details for the file xpatch-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: xpatch-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 31.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for xpatch-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3578e2edee57ea4f90747892d0466a14ebf5a05454efe3d14e949f7677eaa757
MD5 9e583185d410bc91e051e58785c2bbaa
BLAKE2b-256 1d2e56bce8a3f14b44d45e2a08c68642f75f43519e56aeca3f74b1b9de6c7420

See more details on using hashes here.

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