Programs, Jobs and Services
This section covers how to identify and exploit misconfigured programs, scheduled jobs, and services on Linux systems.
SUID/SGID Binaries
SUID (Set User ID) and SGID (Set Group ID) binaries run with the privileges of the file owner/group.
Finding SUID/SGID Binaries
# Find SUID binaries
find / -type f -perm -4000 -ls 2>/dev/null
# Find SGID binaries
find / -type f -perm -2000 -ls 2>/dev/null
# Find both SUID and SGID binaries
find / -type f -perm -u=s,g=s -ls 2>/dev/nullCommon SUID Binaries to Look For
sudosupasswdnewgrpgpasswdchshatmountumountpkexecfindnanovimbash
Exploiting SUID Binaries
Using GTFOBins
Always check GTFOBins (https://gtfobins.github.io/) for known ways to exploit common Linux binaries.
Examples:
Using
findwith SUID:
Using
nanowith SUID:
Using
vimwith SUID:
Cron Jobs
Cron jobs are scheduled tasks that run automatically at specified intervals.
Finding Cron Jobs
Exploiting Cron Jobs
Look for writable scripts executed by cron:
Check for wildcards in cron jobs (command injection):
Example of injecting into a cron job script:
Services
Identifying Running Services
Service Misconfigurations
Check for writable service files:
Check for writable service executables:
MySQL Running as Root
If MySQL is running as root, it can be exploited:
NFS Shares
Network File System (NFS) shares can be exploited if misconfigured.
Identifying NFS Shares
Exploiting no_root_squash
If a share has the no_root_squash option, you can create SUID binaries on it:
Additional Resources
Last updated