6. Insecure System Components


SUID:

ps u -C passwd
grep Uid /proc/<PID>/status
find / -perm -u=s -type f 2>/dev/null
chmod u+s <filename>

Capabilities:

  1. Searching for capabilities:
/usr/sbin/getcap -r / 2>/dev/null
  1. Search for the resulted capabilities in GTFOBins!
    https://gtfobins.github.io/
  2. Exploit and win!

Sudo:

sudo -l


Kernel:

  1. Enumerate the OS, kernel and architecture:
cat /etc/issue
uname -r
arch
  1. Craft a searchsploit query and find a good exploit:
searchsploit "linux kernel Ubuntu 16 Local Privilege Escalation" | grep "4." | grep -v " < 4.4.0" | grep -v "4.8"
  1. Compile the exploit to match the correct architecture and look out for compiling instructions. If possible wait to compile it on target machine itself.
  2. Transfer the binary to the target machine using SCP:
scp cve-2017-16995.c joe@192.168.123.216:
  1. Inspect the file to see if everything is correct before running, especially the architecture:
file cve-2017-16995
  1. Exploit and win!

Try PwnKit!