-1

I am attempting to modify the binary data of an executable program in Linux using Ubuntu.

I have a file called a.out. I can dump it in hex using xxd a.out | less. Then in another terminal window, I run vi a.out.

Vi's data is slightly different in many places than the xxd output. Both display addresses into the file, but the data is different. For example, at the very beginning of the executable, in xxd there are two bytes C006 which in VI display as c380

Does anyone know why they are different? It appears VI is modifying some of the dat afor some reason.

Matthew
  • 3,886
  • 7
  • 47
  • 84
  • Why don't you just use bvi? – oguz ismail Mar 27 '19 at 18:22
  • `vi` doesn't open binary files by default (well, it does, but not usefully), which means you have something in your configuration that allows it to do so. Figure out what `vi` is using and you'll probably be most of the way to answering your own question. – larsks Mar 27 '19 at 18:33
  • 1
    Beware, the original `ex/vi` program does not like processing null bytes... What version of vi are you using exactly? – Serge Ballesta Mar 27 '19 at 18:48
  • Sorry, I forgot to mention I do the ":%!xxd" command in vi to turn it into binary – Matthew Mar 27 '19 at 22:05

1 Answers1

1

I think you're misunderstanding what piping(|) to less is doing.

xxd a.out, will show the hex output of a.out on the terminal.

xxd a.out | less, will simply send the output from xxd to less so you can scroll through it on the command line

What I think you mean to do is xxd a.out > file_to_open_in_vi.txt. This will actually dump your xxd output into a text file that you can then open with vi.

Barry
  • 39
  • 2