Tuesday 24 February 2015

Using vi as a hex editor

I recently had an issue where a license key was unable to be transferred, and attempts to fix using vi/tr/sed (don’t laugh!) didn’t get the file into the correct shape. As it was clearly using a binary forma, I really needed a proper hex editor.

Luckily I was able to list the files with od -ax on two machines, so I knew what I wanted!

It turns out you can use vi as a hex editor - its a commonly known thing out on the internet as ever (my source was http://www.kevssite.com/2009/04/21/using-vi-as-a-hex-editor/).

:%!xxd turns your file into a hex editor style representation

:%!xxd -r turns your edited file back into a binary form which you can then save.

Also handy for editing firmware, binaries, libraries - although be careful, it does seem to add a newline that you’ll need to remove using sed/tr/etc.

No comments: