SUID and SGID exploits
Become root on Linux via SUID:
List files that have SUID or SGID bits set
Exploit
Example: nano
Crack passwords file
List files that have
SUID
orSGID
bits set:
find / -type f -perm -04000 -ls 2>/dev/null
Compare these executables with GTFOBins SUID. The nano text editor has the SUID bit set
Read
/etc/passwd
and/etc/shadow
using nano.Copy contant to local
passwd.txt
respshadow.txt
files.Use the
unshadow
tool to create a file crackable by John the Ripper
unshadow passwd.txt shadow.txt > passwords.txt
Add a user
The other option would be to add a new user that has root privileges.
Using the
openssl
tool, create a password hash for a new user:
openssl passwd -1 -salt <password>
Add this password with a username to the
/etc/passwd
file. Useroot:/bin/bash
to give this user a root shell.Switch to this user.
Notes
SUID (Set-user Identification) and SGID (Set-group Identification) allow files to be executed with the permission level of the file owner or the group owner, respectively.
Such files have an s
bit set showing their special permission level. To find binaries known to be exploitable when the SUID bit is set see GTFObins SUID.