>_ IzzyLab

Hands-on task

This task is step 17 of the course “Linux server security”

Integrity against a manifest: three reports

hard~15 min

After an incident you need to check the /srv/bin directory against the reference checksum manifest /root/manifest.sha256, taken before the break-in. Put together three reports, one name per line, with names exactly as they're written in the manifest (relative to /srv/bin), no hashes or comments:

  • /root/changed.txt: files whose contents don't match the reference;
  • /root/missing.txt: files from the manifest that are gone;
  • /root/extra.txt: files that are in /srv/bin (subdirectories included) but not in the manifest.

Don't change the directory or the manifest.

What you'll practise:
  • sha256sum -c
  • file integrity
  • manifest
  • stdout/stderr
  • comm

Topic breakdown

An integrity check compares current checksums with reference ones taken in a known-clean state. sha256sum -c reads the manifest and prints one line per file in it: matched (OK), didn't match (FAILED), or the file couldn't be opened (FAILED open or read); for the last case it also writes the reason to the error stream. That's why you parse the output by the whole status: "FAILED" as a substring mixes changed files with deleted ones. Names in the manifest are stored the way they were passed when it was created, usually relative to the working directory, hence the need to run the check from that same place. The main limitation: -c checks only what's listed in the manifest, so a planted file (a backdoor, an extra library) stays invisible. You find it by comparing two sorted lists of names: comm shows the lines that are only in one of them. Keep the reference copy away from the system you're checking, or it will be swapped out along with the files.

What's checked

  1. changed.txt: exactly the changed files
  2. missing.txt: exactly the missing files
  3. extra.txt: exactly the files outside the manifest
  4. the directory and the manifest are unchanged

What it looks like