Giter Club home page Giter Club logo

binary-diff's Introduction

binary-diff

usage: binary_diff.py [-h] [-m MIN_MATCH_LEN] [-d MAX_DISTANCE] [-t] [-p]
                      input_file input_file

Compare two binary files. The algorithm: repeatedly find the longest prefix of
file 1 in file 2, advance in file 1 and mark the addresses in file 2 as used.
Output lines consist of three integers separated by commas: position in file
1, position in file 2, length. If one of the positions is empty, the line
denotes an unmatched chunk, otherwise a match. Positions start from 0. E.g.
'10,20,3' means bytes 10-12 in file 1 are identical to bytes 20-22 in file 2,
and '40,,5' means no match in file 2 was found for bytes 40-44 in file 1.

positional arguments:
  input_file            Two binary files to compare (need not be the same
                        size).

options:
  -h, --help            show this help message and exit
  -m MIN_MATCH_LEN, --min-match-len MIN_MATCH_LEN
                        Minimum length of matches to find. Default=8.
  -d MAX_DISTANCE, --max-distance MAX_DISTANCE
                        Maximum absolute difference of addresses in file1 and
                        file2 (default = -1 = no limit); note: does not work
                        at the moment.
  -t, --tabular         Print results in tabular format instead (hexadecimal
                        address ranges).
  -p, --progress        Print messages that indicate progress.

Example

Suppose we have the following files:

  • a.txt: abcdefgh ijklmnop qrstuvwx ABCDEFGH
  • b.txt: ijklmnop abcdefgh qrstuvwx IJKLMNOP

The command python3 binary_diff.py a.txt b.txt will print:

"position in file1","position in file2","length"
0,9,9
9,0,9
18,18,9
27,,8
,27,8

To do

  • If the --max-distance option is used (not -1), the program will incorrectly ignore some matches.

binary-diff's People

Contributors

qalle2 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.