>_ IzzyLab

Hands-on task

This task is step 13 of the course “Investigating a server”

SUID where it shouldn't be

medium~5 min

SUID files in /usr/bin are normal (passwd, su…), but in /usr/local and /opt there shouldn't be any: that's where your own software goes, and SUID there is a common trace of an attacker who has gained persistence. Find all regular files with the SUID bit in /usr/local and /opt and write their paths, one per line, to /root/suid-ioc.txt.

What you'll practise:
  • suid bit
  • find -perm
  • file permissions
  • security audit
  • investigation

Topic breakdown

The SUID bit makes a program run with the privileges of the file's owner rather than the user who started it. System utilities like passwd don't work without it, but a copy of bash or find with SUID root is a ready-made ladder to root for any user, so after a break-in one of the first things to look for is SUID files outside the standard locations. find selects them by permission mask: -perm with a - prefix requires the given bits to be set regardless of the rest; SUID is 4000, while the similar-looking SGID (2000) is a different bit. Several directories are passed to find as a list.

What's checked

  1. planted SUID files found
  2. the list is exactly the SUID files

What it looks like