Privileges Exploitation
Writable /etc/passwd
Create a new user entry in root group and append it to the /etc/passwd file
Writable /etc/sudoers
Allow current user to invoke any program with sudo without needing the password
Elevated shell with sticky bit
By exploiting an application running as root (for instance a database or a script) it is possible to obtain an elevated shell by executing the following commands within the elevated application:
SUID exploit
Built-in exploitable binaries
Shared library hijack
check for missing .so files
Shared library code
Put the file in the path of the missing library or replace it if you can write in the folder.
Compile as
Relative path hijack
Find calls to system binaries in executable file
Search for calls to executables with relative paths, for instance instead of /bin/cp
look for cp
boilerplate code
compile and execute
Add the /tmp folder to the $PATH variable and compile the malicious program with the same name as the relative path executable invoked in the vulnerable executable. In this way the generated malicious program will be detected and executed before the system one.
Writable service files
Can be found by searching for .service files with write permission or by checking write permissions with sudo -l
File template
the Exec* instructions can be hijacked to execute arbitrary scripts
The basic structure of a service file is the following:
Manage services
Socket Code Injection
When an application creates a socket running under root it is possible to send commands to the socket to create a suid-privileged shell and escalate privileges. These applications can be recognized because they create a .s file in a specific folder (usually /tmp)
If the target machine does not have socat installed execute the following command
Run the application to spawn the socket then execute the following commands to spawn a privileged shell
Last updated