>_ IzzyLab

Hands-on task

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

A tampered update

medium~10 min

The monitoring agent on the server was updated from a mirror, and strange things started happening after that. The update was saved in base64: /root/update/agent.b64. The vendor publishes a checksum in /root/update/agent.sha256 (the sha256sum format: hash agent.bin).

Decode the update into /root/update/agent.bin, compare its SHA-256 with the published one and write one word to /root/update/verdict.txt: OK if they match, or TAMPERED if they don't.

What you'll practise:
  • base64
  • sha256sum -c
  • integrity check
  • exit code
  • investigation

Topic breakdown

The integrity of a downloaded file is checked against a checksum published separately from it: if the file was swapped on a mirror, the hash won't match. sha256sum can not only compute a hash but also check files against a list in its own format (hash name) — check mode reads names from the list relative to the current directory and returns a non-zero code if at least one file doesn't match. That exit code is easy to turn into a verdict with a conditional. If the file came in base64, the hash must be computed over the decoded bytes — the hash of the base64 text will be different.

What's checked

  1. update decoded
  2. verdict is correct

What it looks like