Consider this another way. How can you store anything in ones and zeros?
Is not every file binary?
What makes a binary file binary? That it doesn’t look like a text file,
but that’s about it. Just because something is compiled doesn’t mean
there are not strings in it. A fun security-ish example of this is when
somebody “secures” an application by requiring a password inside it when
that password is just assigned as a constant or something without any
obfuscation or hashing. Run strings against the file, find the right
string that is the super-secret password, run the file without issues.
On 09/29/2010 09:06 PM, soldier101 wrote:
> I lately observed that grep can be used to search (try searching a
> function name) binaries and object files. Here is an example:
> $ grep “main” a.out
> Binary file a.out matches
> How can grep find names in a binary file? Is a.out not completely a
> binary file(does it contain some symbols?) ?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
I think the limitation is not in reading strings in binaries in the case of grep but in printing them to standard output (or more precisely to the terminal). You can use the quiet option of grep and take an action depending on the result :
In principle every file on Unix/Linux is a binary file. Text files are just a special case where by application (not kernel) convention lines are separated by NL and the content is generally human readable. grep works on line oriented files. So it’s treating your executable as a file of mostly “very long” lines, separated where there happens to be a NL by chance.