Abusing SUID and GUID Files
| Command | Description |
chmod | Modify file/dir permissions |
find / -perm -u=s -type f 2>/dev/null | Search for vulnerable binaries |
find / -type f -perm -04000 -ls 2>/dev/null | Search for vulnerable binaries |
About
- First step in methodology is to check for files with the SUID/GUID bit set
- These files can be run with the permissions of their owner/group
- Can be leveraged to get a shell with elevated privileges
- All files have 3 permission sets: user/group/others
- Set bits to allow/deny three operations: read/write/execute
| Permission | On Files | On Directories |
| SUID Bit | User executes the file with permissions of the file owner | - |
| SGID Bit | User executes the file with the permission of the group owner. | File created in directory gets the same group owner. |
| Sticky Bit | No meaning | Users are prevented from deleting files from other users. |
| permissions | bits | account |
| rwxrwxrwx | 777 | admin |
| rwxr-xr-x | 755 | user |
| rwsrw-rw- | 4766 | SUID |
| rwxrwxr-x | 2775 | GUID |
Finding SUID binaries
# A
find / -perm -u=s -type f 2>/dev/null
# B
find / -type f -perm -04000 -ls 2>/dev/null