Linux Privilege Escalation

System Info

Obtain information about the system architecture, distribution, and kernel version.

uname -a  # System information
lsb_release -a  # Distribution information
getconf LONG_BIT  # System architecture
cat /proc/version  # Kernel version
cat /etc/os-release  # OS details

Path

Check if you have write permissions for any directory in the PATH.

echo $PATH | tr ':' '\n' | sort -u | xargs -I{} bash -c 'if [ -w "{}" ]; then echo "[+] {}"; fi'

Environment Variables

Sometimes we can find password or sensitive information in environment variables.

env  # Environment variables
set  # Shell variables

Groups

List all the groups users belongs to.

Docker

If you belong to the Docker group, you could mount the filesystem within a container and have full access to it, allowing you to modify it.

LXD/LXC

Similar to Docker, with LXD/LXC, we can also mount the filesystem within a container, granting full access to it.

Sudo

https://gtfobins.github.io/

Capabilities

https://book.hacktricks.xyz/linux-hardening/privilege-escalation/linux-capabilities

SUID

https://gtfobins.github.io/

Open Ports

Cron Jobs

https://book.hacktricks.xyz/linux-hardening/privilege-escalation#scheduled-cron-jobs

Process Monitor

You can exclude specific patterns using the grep -Ev command. For example, to filter out processes from the current user: grep -Ev "kworker|$USER"

User Files

Passwords