DARKPC.NET | Website Defacement Investigation and Recovery Lab

This intermediate exercise uses a fictional café, two static snapshots, and
six synthetic Apache access-log events. Use an ordinary account on Kali Linux
or another Linux system with Bash, GNU coreutils, diff, grep, awk and unzip.
The exercise works offline with no web server.

Save website-defacement-exercise.zip in your Downloads directory. Open a
terminal there. Use its actual path if you saved it somewhere else.

    workspace=$(mktemp -d) &&
      unzip website-defacement-exercise.zip -d "$workspace" &&
      cd "$workspace/lab"

The lab/ folder contains clean_site/ (trusted baseline), defaced_site/
(affected snapshot), logs/access.log (fictional UTC activity), and hashes.txt
(the three original baseline digests). Start with WORKSHEET.md. Review
SAMPLE-INCIDENT-REPORT.md after completing your own analysis. Use
RECOVERY-CHECKLIST.md when validating the staging copy.

1. Establish the baseline.

    sha256sum --strict -c hashes.txt

Expect three OK results. In a real case obtain the manifest from a trusted,
independently protected source. Record the archive's hash before extracting
if it is being handled as evidence.

2. Preserve the exercise inputs, then analyse the working copy.

    umask 077
    case_dir=$(mktemp -d ./case.XXXXXX) &&
      cp -a defaced_site logs "$case_dir/" &&
      (sha256sum defaced_site/* logs/access.log > "$case_dir/evidence.sha256") &&
      (cd "$case_dir" && sha256sum --strict -c evidence.sha256)

Record the original source, collection time and UTC offset, collector and
destination. Keep the originals untouched. Compare the baseline and copies.

    diff -qr clean_site "$case_dir/defaced_site"
    diff -u clean_site/style.css "$case_dir/defaced_site/style.css"
    sha256sum clean_site/* "$case_dir"/defaced_site/*

GNU diff returns 1 when differences exist and 2 if trouble occurs.
Two files differ: index.html and style.css. The About page matches. The
stylesheet's extra comment changes its checksum even though its rules match.

3. Investigate the fictional access log.

    nl -ba "$case_dir/logs/access.log"
    grep -nF '"POST /admin/content ' "$case_dir/logs/access.log"
    awk -F'"' '{print NR, $2, $3}' "$case_dir/logs/access.log"

Log timestamps are UTC (+0000). The POST is a lead. HTTP 200 is a response
status. The log does not record write success, the POST body or the identity
of the operator. Record a window between the last homepage response matching
the baseline size and the first matching the affected size. Sizes support
correlation. The file comparison confirms differences between the snapshots.

4. Restore into a fresh local staging directory.

    sha256sum --strict -c hashes.txt &&
      restored=$(mktemp -d ./restored_site.XXXXXX) &&
      cp -a clean_site/. "$restored/" &&
      sed 's|  clean_site/|  |' hashes.txt > "$restored.sha256" &&
      (cd "$restored" && sha256sum --strict -c "../${restored##*/}.sha256") &&
      diff -qr clean_site "$restored"

Expect two sets of three OK results and no diff output. The second set checks
the staged files. Inspect the restored pages in a local browser if desired.
A live incident requires containment and remediation before return to public
service. This exercise ends at local verification.
