Exploitation and privilege escalation
Setuid and setgid
A permission bit that makes a program run as its owner, not as whoever started it — safe on a few tools, dangerous on one that runs other commands.
The setuid bit makes a program run as its owner, not as whoever started it. Set with chmod u+s, it shows
as -rwsr-xr-x, and find / -perm -4000 finds them. passwd needs it to edit the root-only password file. The
danger is a setuid-root program that can run other commands (find -exec, vim): any user gets a root shell.
[[gtfobins|GTFObins]] lists them. Setgid does the same with the file's group.
Read next
- Privilege escalation Turning a limited login on a host into full control, by abusing one thing the system was left doing wrong.
- GTFObins A catalogue of ordinary Unix binaries that can be bent into reading files, writing files or spawning a shell — the key to abusing a sudo rule or a setuid bit.
- Stack buffer overflow Writing past a fixed stack buffer until the write reaches the function's saved return address, then choosing where the function returns to.