Linux Shared Libraries Attacks
two types of libraries exist in Linux:
static libraries
(denoted by the .a file extension)dynamically linked shared object libraries
(denoted by the .so file extension)
There are multiple methods for specifying the location of dynamic libraries, so the system will know where to look for them on program execution.
This includes the
-rpath
or-rpath-link
flags when compiling a program, using the environmental variablesLD_RUN_PATH
orLD_LIBRARY_PATH
, placing libraries in the/lib
or/usr/lib
default directories, or specifying another directory containing the libraries within the/etc/ld.so.conf
configuration file.Additionally, the
LD_PRELOAD
environment variable can load a library before executing a binary.The functions from this library are given preference over the default ones. The shared objects required by a binary can be viewed using the
ldd
utility.
The code above lists all the libraries required by
/bin/ls
, along with their absolute paths.
LD_PRELOAD Privilege Escalation
get the exuctable that can run as root or the user you want to get as
root.c
you get shell of that user
Last updated