Thursday, May 13, 2010

strings - smart and useful

Someone gives you up a binary a.out and says he has added some line like this
printf("Hello Universe");
Now the changes may be much bigger then the example. During your testing you do not get the desired result as was expected after his changes.
How do you confirm that he has not misplaced his binaries and handed you a wrong one?
So, if there is a string involved in the change; then you can use the strings command and confirm it.
$ strings a.out | grep Universe
Hello Universe


Better explanation on why to use strings is given here as http://www.oreillynet.com/pub/a/oreilly/linux/news/linuxnut_0800.html

'''

Sometimes you really want to see inside a binary file. Maybe there isn't a manpage and you're looking for usage information, or perhaps you're looking for information about who wrote a program or what application a file is associated with.

The strings command is perfect for that purpose--it searches through a file looking for sequences of printable character strings and writes them to standard output. You can pipe the output through a pager like more, or if you are looking for particular text, you can pipe the output to the grep command.

'''

No comments:

Post a Comment