0

I have a compiled executable (binary) file - mybin - which grep indicates contains a positive match with a given text string - Cats.

grep "Cats" mybin
Binary file mybin matches

If I use the -a flag with grep, I can now see the actual match:

grep -a "File" mybin
<lots of text> (QString)Cats <lots of text>

Just to be clear, this is not a plain text string within the binary file i.e. I cannot see it if I open the file with a text editor.

What I want to do is replace occurrences of the string Cats within the binary file with the string Bear and keep the executable as a working executable.

How do I do this without changing it in the source code and recompiling the binary? Is such an operation even possible without corrupting the executable file and its operation?

If it is possible:

  1. How would do I do it?
  2. Are there any pitfalls I need to be aware of, for example the replacement string must be the same length as the original string (e.g. Cats -> Bear is ok but Cats -> Dragons is not).

Any help would be greatly appreciated.

Mark
  • 101

0 Answers0