I have a binary that has to be copied over serial port to the device that has hexedit installed.
How to get hex dump of the binary on Linux (preferably in Python) in a format that can be simply inserted into hexedit?
I have a binary that has to be copied over serial port to the device that has hexedit installed.
How to get hex dump of the binary on Linux (preferably in Python) in a format that can be simply inserted into hexedit?
Copyright © 2021 Jogjafile Inc.
Restating the question a little, I think you want to generate a hex dump of a binary file on one machine and save it in the clipboard, then start
hexediton a different machine and paste the clipboard intohexedit- thereby transferring a binary file.So, let's generate a recognisable, small PNG image which is a binary file, just using ImageMagick:
Now look at in hex:
That looks good, but we don't want all the address offsets down the left side, or the ASCII on the right side or the spaces and newlines, so we can use a "plain" dump:
If you don't have
xxd, you can useodinstead, something like this:And now we want to get that into our clipboard so we can paste it into the
hexediton the remote machine. The command will vary between operating systems.On macOS:
On Linux, something like:
Or:
Then go to the remote machine, create an empty file called
pasted.png, starthexeditand paste into the file, and save:PASTE is probably SHIFTINSERT, or middle mouse button, or CtrlV.
It looks like this in
hexedit:Now open the (binary) file to check it: