Saturday, June 7, 2008

Editing binary files with xxd

First to hexdump the binary:
xxd -c 12 binaryfile.bin test.txt

the output to the file test.txt will be something like this:
0000000: 7f45 4c46 0101 0100 0000 0000 .ELF........
000000c: 0000 0000 0200 0300 0100 0000 ............

edit the hexadecimals, then to convert the file back to binary, type:
xxd -r test.txt newbinary.bin