Host Security  «Prev  Next»

Lesson 11Finding modified and sticky files
ObjectiveCheck for Files that may have been modified by the Intruder
If your system has been compromised, or if you think it might have been compromised, you should immediately check for files that may have been modified by the intruder. The intruder may have changed files in an extremely subtle way to install a backdoor so they can break into the system again. For example, the intruder might alter a standard script so that a particular parameter opens a backdoor, or he or she may simply make a vulnerable script sticky, or executable only by the script's owner, so they can use it to break root. The find command is an extremely useful utility for finding such changes.

find command

The find command is used to locate files in the specified path or paths that match the criteria given by the options. The following table displays various usages of the find command.

find <path/s> -mtime -N -ls Modified within N*24hours
find <path/s> -ctime -N -ls Mode changed (e.g., sticky) within N*24 hours
find <paths> -perm -6000 sSuid or sgid applications
find <paths> -perm -6000 -ctime -N Sticky and mode changed within N*24 hours

Red Hat Linux Certification
The following MouseOver demonstrates the use of the find command.
  1. find command
  2. /etc: These are the user specified paths that will be searched for modified files
  3. -mtime: As an option that locates all files modified within a user-specified number of days
  4. -l : The number of days as specified by the user
  5. -ls :An option requesting a list containing additional information about modified files
  6. /etc/passwd: This output displays all the files under the /etc directory that have been modified in the past 24 hours

Linux Find Command
You should have some idea when the break-in may have occurred, so use the find command to search for file modifications within the timeframe you believe the attack occurred. For example, the following will find all files in the /etc, /sbin, and /usr/sbin directories whose contents have been modified within the past 48 hours:

find /etc /sbin /usr/sbin -mtime -2 -ls

Because sticky files are a particular security hazard, you may wish to look specifically for all sticky files on your filesystem. The following table shows various find command lines that search for sticky files.
find /etc /sbin /usr/sbin -ctime -1 -ls Ffinds all sticky (user or group) files in the requested directories
find / -perm -6000 Ffinds all sticky (user or group) files on your filesystem
find / -perm -6000 -ctime -2 Ffinds all sticky (user or group) files on your filesystem, whose attributes have been changed within the past 48 hours

For more information, consult the man pages using the command man find.
The next lesson describes the cron facility.
Potentially Cracked Abused Files
Click on the link to learn about Potentially Cracked Abused Files.