bin_replace_string edits C-style strings in precompiled binaries. This is intended to be useful to replace arbitrary strings in binaries whose source code is not available. If you find yourself using this utility on a GPL-licensed program, you're using the wrong method ;-). However, because of the nature of compiled binaries, bin_replace_string may only replace a given C-string with a shorter C-string.
One supposed use case is where a precompiled binary tries to access an arbitrary path which is both incorrect and unconfigurable.
I recognize that bin_replace_string is a simple and limited tool. If you want to modify portions of an ELF header itself, for example, you should not use bin_replace_string. Instead, try patchelf which is designed to edit ELF headers, such as RPATH. It even knows how to replace short strings (in ELF headers, not compiled code or C strings) with longer ones.
Documentation is shipped with the sources and installed as a manpage using the txt2man(1) utility. You may read bin_replace_string(1) online.
Ubuntu users may use binki's
PPA to install bin_replace_string (the package is
called bin-replace-string because debian uses the scheme
P=${PN}_${PV} and doesn't allow _ in
${PN}).
The first release of bin_replace_string was unix-style filter-based. The current release has a completely different CLI, which is documented in the man page which was first written for this release.
Supports loading and saving files through libelf at the much appreciated suggestion of Flameeyes. When interpreting a file using libelf (the default mode), only the machine code in .rodata is modified because this is the section of an ELF file which will hold statically allocated strings — bin_replace_string doesn't pretend to be useful for modifying other strings in binaries. If there is a binary file which isn't ELF formatted though or there is another alternative usecase, the -r option may be used to treat the input as a BLOB like bin_replace_string-0.1.
First release. Treats every file as a large BLOB, ignoring the semantics about ELF headers and the like. Can only act as a unix-style filter, IIRC.
bin_replace_string depends on the following packages:
Please report bugs at our local bugtracker. Also, feel free to speak to binki directly via email or IRC.
The sourcecode for bin_replace_string is managed by Mercurial. The hgweb interface is available at at http://ohnopub.net/hg/bin_replace_string. One may clone the repository with the following command:
$ hg clone http://ohnopub.net/hg/bin_replace_string