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/null

Common SUID Binaries to Look For

  • sudo

  • su

  • passwd

  • newgrp

  • gpasswd

  • chsh

  • at

  • mount

  • umount

  • pkexec

  • find

  • nano

  • vim

  • bash

Exploiting SUID Binaries

Using GTFOBins

Always check GTFOBins (https://gtfobins.github.io/) for known ways to exploit common Linux binaries.

Examples:

  1. Using find with SUID:

  1. Using nano with SUID:

  1. Using vim with SUID:

Cron Jobs

Cron jobs are scheduled tasks that run automatically at specified intervals.

Finding Cron Jobs

Exploiting Cron Jobs

  1. Look for writable scripts executed by cron:

  1. Check for wildcards in cron jobs (command injection):

  1. Example of injecting into a cron job script:

Services

Identifying Running Services

Service Misconfigurations

  1. Check for writable service files:

  1. 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