|
1 | 1 | # bsdiff
|
2 |
| -A tool to diff bitstream files |
| 2 | +An experimental tool to diff bitstream files |
| 3 | + |
| 4 | +I'm trying to reverse engineer some proprietary binary files, and I |
| 5 | +noticed that these files are bit streams (as opposed to byte stream). |
| 6 | + |
| 7 | +My approach is to compare two files that have minimal diferrence and |
| 8 | +see how the bitstream behave, I need to be able to detect bit flips as |
| 9 | +well as bit insertion/deletion between two files. |
| 10 | + |
| 11 | +This is a very beta version of such a tool, it attempts to mimic the |
| 12 | +unix "diff" tool, but display bits instead of text. |
| 13 | + |
| 14 | +For now, the algorithm is very stupid and simple, it doesn't yet |
| 15 | +understand the concept of context as used in GNU diff and patch. |
| 16 | + |
| 17 | +I might improve this tool to fit my needs. |
| 18 | + |
| 19 | +# Example output |
| 20 | + |
| 21 | +In the example below, you can see that at position 0, the first file |
| 22 | +contains "1100" where as the second file contains "0010". |
| 23 | + |
| 24 | +Then the files are identical up to the 144975'th bit. At this bit |
| 25 | +position, the first file contains "110" whereas the second one |
| 26 | +contains "01100", that is the second file as 2 more bits that the |
| 27 | +first one. |
| 28 | + |
| 29 | +The two files have then roughly 10k identical bits, after which there |
| 30 | +a new difference "110" vs "011010110", ... |
| 31 | + |
| 32 | +As you might have noticed, this tool is able to track bit assertion |
| 33 | +and removal. |
| 34 | + |
| 35 | + $ bsdiff Si8605AC-B-IS1.bxl Si8606AC-B-IS1.bxl |
| 36 | + --- Si8605AC-B-IS1.bxl |
| 37 | + +++ Si8606AC-B-IS1.bxl |
| 38 | + @@ [4,0] -4,-4 +4,4 @@ |
| 39 | + -1100 |
| 40 | + +0010 |
| 41 | + ^^^ |
| 42 | + @@ [3,2] -144975,-3 +144975,5 @@ |
| 43 | + - 110 |
| 44 | + +01100 |
| 45 | + ^^ ^ |
| 46 | + @@ [3,6] -152419,-3 +152421,9 @@ |
| 47 | + - 110 |
| 48 | + +011010110 |
| 49 | + ^^^^^^ |
| 50 | + @@ [2,0] -154292,-2 +154300,2 @@ |
| 51 | + -11 |
| 52 | + +01 |
| 53 | + ^ |
| 54 | + ... |
0 commit comments