Monday, November 28, 2005

On The Hacked Track

1. Viewing the dependencies of a binary
ldd gives you the dynamic libraries that a file depends on.
$ ldd binaryfile

2. Viewing the symbols in a file
nm gives you the list of symbols in the file. Functions that are exported by the library will be present as symbols. Many files are stripped of symbols before they are released, though.
$ nm binaryfile/libraryfile

3. Interposing
On many *NIX variants, you can set a dynamic library of your choice to be searched first when dynamic library calls are made.
Set the value of LD_PRELOAD to the full path of the library file you want to be executed in preference to other libraries.

Take an executable and determine its dependencies. View the symbols in those library-files. Make your own library-file with implementations for the symbols that seem to be of relevance to you. Set the LD_PRELOAD variable to the name of your library file. Run the executable.


No comments: