Linux privilege escalation
Manual enumeration
User
Other Users
Privileges
File system
Hostname
OS and architecture
Processes and services
Network
Scheduled tasks
Applications/patch levels/drivers/kernel modules
Readable/writeable directories
Unmounted disks
Sensitive files
Passwords
Search the file system for passwords. Try additional search terms (pass, etc.).
SSH keys
Search the filesystem for SSH keys. Public keys are typically stored in the "authorized_keys" folder, private keys are stored as "id_rsa".
Automated tools
Exploitation paths
SUID Files
SUID files allow individuals to execute files using the privileges of another user. They are identifiable by an "s" in the third character of the root permissions for a file. You can search manually with:
If you find identify a SUID file, check GTFO bins for exploits
Capabilities
The exploitation for capabilities is similar to that of SUID files. Search for capabilities with:
Look for "+ep" at the end of any returned items. If present, exploitation possible.
Execution
Run Python to escalate
Other possibly exploitable capabilities include perl, tar, openssl (check GTFO bins)
Scheduled Tasks
Columns represent minute, hour, day of month, month, day of week. Asterisks in columns indicate "all", asterisks in all fields indicates that the task runs every minute/hour/day of month/month/day of week
Exploitation
First, check the file type using the file
command and whether or not you have write access. Sometimes replacing the file with one created on your attacking machine is easier than modifying the file that is in place. If so, rename the current file as *.old and use wget to replace with the version created on your attack machine.
NFS root squashing
Check cat /etc/exports
for results indicating "no_root_squash", indicating folders that are shareable and can be mounted. If available, remote commands are executed as root.
Exploitation
From the attacking machine:
Search for mountable shares
Create a new directory:
Mount the folder:
Create malicious file:
Compile the file:
Return to the victim machine, navigate to the target directory (/tmp), and execute the file
Docker
If you are in the Docker group, check to see which containers are available:
Run the image:
Last updated