Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Scenario test · 70 minutes

Handle a case archive from a colleague

After this lesson you can
  • Check, list and extract an archive from outside without risk
  • Find the evidence in it by name, size, age and content, and triage its login log
  • Fix permissions, record your work and hand in a report with a new archive
Lab files of this lesson (12)

The lab folder as it stands after this lesson. Unzip it in ~/krlab.

More

The zip holds every file that the course has printed up to here. To start this lesson with the files of the earlier lessons only, take the zip of the lesson before. Type the code yourself first: you learn more.

Scenario

Dana, a colleague at a small company, sends you the archive case-417.tar.gz and a file with its SHA-256 fingerprint. It holds the logs and notes of a break-in on the web server krbox, and she wants a second pair of eyes before she calls the owner. You do not know what is inside, and you must not trust it. You work only in your lab, and you run nothing from the archive.

Run this block once. A script with fixed content builds the archive and its fingerprint in ~/krlab/linux-basics/inbox, so that every reader has the same data. It is not a task. set -e stops the script at the first error, and ln -s makes the two symbolic links that the archive holds.

mkdir -p ~/krlab/linux-basics && cd ~/krlab/linux-basics
cat > build-case.sh <<'EOF'
#!/bin/bash
# build-case.sh - builds the case archive with fixed content
set -e
mkdir -p ~/krlab/linux-basics && cd ~/krlab/linux-basics
rm -rf inbox build-417
mkdir -p inbox build-417/case-417
cd build-417/case-417
mkdir logs notes keys bin tmp
echo "Case 417: break-in on the web server krbox. Collected by Dana." > README.txt
cat > logs/access.log <<'LOG'
203.0.113.77 - - [21/Nov/2026:03:10:01 +0000] "GET /admin HTTP/1.1" 403 199
203.0.113.77 - - [21/Nov/2026:03:10:04 +0000] "POST /login HTTP/1.1" 401 150
203.0.113.77 - - [21/Nov/2026:03:10:09 +0000] "POST /login HTTP/1.1" 200 812
203.0.113.77 - - [21/Nov/2026:03:12:30 +0000] "POST /upload.php HTTP/1.1" 200 20
192.0.2.21 - - [21/Nov/2026:08:00:01 +0000] "GET /index.html HTTP/1.1" 200 5120
LOG
cat > logs/auth.log <<'LOG'
Nov 21 03:09:40 krbox sshd[2101]: Failed password for root from 203.0.113.77 port 40122 ssh2
Nov 21 03:09:44 krbox sshd[2101]: Failed password for root from 203.0.113.77 port 40124 ssh2
Nov 21 03:09:50 krbox sshd[2105]: Accepted password for root from 203.0.113.77 port 40130 ssh2
Nov 21 08:02:03 krbox sshd[2230]: Accepted publickey for dana from 192.0.2.44 port 51234 ssh2
LOG
echo "Nov 14 09:00:00 krbox sshd[900]: Accepted publickey for dana from 192.0.2.44 port 50000 ssh2" > logs/auth.log.2
echo "Nov 14 09:05:00 krbox nginx: worker started" > logs/error.log
cat > notes/timeline.txt <<'TXT'
03:09 password guessing from 203.0.113.77
03:10 login as web admin
03:12 file upload.php written (a web shell?)
TXT
seq 1 2500 > tmp/cache.dat
echo "token=not-a-real-token" > keys/deploy.key
printf '#!/bin/bash\necho collecting\n' > bin/collect.sh
chmod 666 keys/deploy.key
chmod 4755 bin/collect.sh
ln -s logs/auth.log latest.log
ln -s /etc/shadow notes/shadow-copy
touch -d "2026-01-10 09:00" logs/auth.log.2 logs/error.log
cd ..
tar -czf ../inbox/case-417.tar.gz case-417
cd ../inbox
sha256sum case-417.tar.gz > case-417.tar.gz.sha256
cd ..
rm -rf build-417
echo "built inbox/case-417.tar.gz"
EOF
bash build-case.sh
built inbox/case-417.tar.gz

Your tasks

Work in ~/krlab/linux-basics. There are no commands here. Choose the tools yourself, and keep the order.

  1. Before you open it. In inbox, check the archive against its fingerprint file. List its names, with owners and modes, and do not extract anything yet. Find the members that are a warning sign: a link that points outside the case folder, and a file with the SUID bit.
  2. Open it safely. Make the folder work, and extract the archive into it with the option that names the target. Do not run anything from it.
  3. Find the evidence. In work/case-417, find the regular files by name (.log; -type f leaves out links), by size (more than 10 KiB), by age (changed more than 30 days ago) and by content (the address 203.0.113.77).
  4. Triage the login log. In work/case-417/logs/auth.log, count the failed logins, rank the addresses of the failures, and list the accepted logins with user and address. Your own triage.sh of lesson 11 does it in one run, or use the tools of lessons 4 to 6.
  5. Follow the link. The case holds a link latest.log. Find where it points.
  6. Fix the permissions. The key file keys/deploy.key must be readable and writable by you only. The script bin/collect.sh must be readable and runnable by you and your group, writable by you only, and closed to everyone else. No file may keep the SUID bit.
  7. Record your work. Make the folder report. With one command, save the sorted list of the regular .log files in report/logs.txt and show it on the screen as well.
  8. Pack your findings. Make the folder findings with three things: a copy of logs.txt, a file summary.txt with one line of your own, and a folder scratch with any file. Pack it into findings.tar.gz without scratch.

Answer the results here.

Hand in

Write a short report in the file ~/krlab/linux-basics/report/report.md, with an editor of lesson 7. It is the proof of your work, and you can show it to an employer. Keep it to one page, with these headings:

  1. Summary. Three sentences for Dana: what the archive holds, how sure you are, and what she must decide.
  2. Checks before opening. What you checked, and the warning signs that you found in the list.
  3. Findings. For each fact: the file, the command and what it shows. Use the four searches of task 3 and the link of task 5.
  4. Evidence from the logs. The output of the triage of task 4: who failed, who got in, from which address. Say what it shows and what it does not show.
  5. Changes I made. The permissions that you fixed, and why.
  6. Next steps. What Dana does next, in order.

Do not claim more than the evidence shows. Mark every guess as a guess.

Review your work

One model solution

Results. 17 names. sha256sum -c prints case-417.tar.gz: OK. The link notes/shadow-copy points to /etc/shadow, outside the case. The file bin/collect.sh has the SUID bit in the archive (-rwsr-xr-x). In work: 3 .log files, tmp/cache.dat over 10 KiB, 2 old files (auth.log.2 and error.log), 3 files with the address (access.log, auth.log, timeline.txt). logs/auth.log holds 2 failed logins, and the accepted root login comes from 203.0.113.77 (the other accepted login is dana from 192.0.2.44). latest.log points to logs/auth.log.

How to find them. Each result comes from tools of this course, for example:

cd ~/krlab/linux-basics/inbox
sha256sum -c case-417.tar.gz.sha256
tar -tf case-417.tar.gz | wc -l
tar -tvf case-417.tar.gz
cd .. && mkdir work
tar -xzf inbox/case-417.tar.gz -C work
cd work/case-417
find . -type f -name "*.log"
find . -type f -size +10k
find . -type f -mtime +30
grep -rl 203.0.113.77 .
bash ~/krlab/linux-basics/triage/triage.sh logs/auth.log
readlink latest.log
chmod 600 keys/deploy.key
chmod 750 bin/collect.sh
mkdir -p ~/krlab/linux-basics/report
find . -type f -name "*.log" | sort | tee ~/krlab/linux-basics/report/logs.txt
cd ~/krlab/linux-basics
mkdir -p findings/scratch
cp report/logs.txt findings/
echo "Attacker address 203.0.113.77, see access.log" > findings/summary.txt
echo x > findings/scratch/tmp.txt
tar -czf findings.tar.gz --exclude=scratch findings
tar -tf findings.tar.gz | wc -l

grep -r does not follow the link shadow-copy, so the search stays inside the case. The extraction of a normal user already drops the SUID bit, but the list shows what the sender stored, and root would keep it.

A model report.

Case 417 - review of the archive from Dana

Summary
The archive holds web and login logs, notes, a key file and a script of a
break-in on krbox. The logs show password guessing and a root login from
203.0.113.77, and then an upload of upload.php. I am sure of the logs, not
of the cause. Dana must decide whether to take the server offline.

Checks before opening
sha256sum -c: OK, so the file is the one that was sent (not who sent it).
tar -tvf: notes/shadow-copy points to /etc/shadow, outside the case.
bin/collect.sh has the SUID bit. I extracted into an empty folder and ran
nothing from it.

Findings
files with the address: grep -rl gives access.log, auth.log, timeline.txt
logs/access.log: POST /upload.php from the same address at 03:12:30
tmp/cache.dat is the only file over 10 KiB; I did not read it as evidence.
latest.log is a link to logs/auth.log.

Evidence from the logs
triage.sh logs/auth.log: 2 failed logins, both from 203.0.113.77 (root).
Accepted logins (times from the log): root from 203.0.113.77 at 03:09:50,
6 seconds after the second failure, and dana from 192.0.2.44 at 08:02:03.
The first fits password guessing that worked. It does not show how the attacker found the password.
logs/access.log: POST /upload.php from the same address at 03:12:30

Changes I made
keys/deploy.key 600: a key must not be open to all.
bin/collect.sh 750: no SUID, no write for the group.

Next steps
1. Keep the original archive and its fingerprint file.
2. Block 203.0.113.77, and look for upload.php on the server.
3. Rotate the deploy key (the one in the archive must be treated as seen).
4. Ask Dana why the archive holds a link to /etc/shadow.

Mark your report

You mark this yourself, or you ask a colleague or a mentor to mark it. The page checks the numbers above; it cannot read your report.

CriterionNot yetMeets the standardStrong
FindingsMisses the outside link or the SUID script.Finds both, the big and old files, the address files, latest.log, and the failed and accepted logins.States that grep -r skips links.
EvidenceFacts with no source.Each fact names a file and a command to re-run.Quotes the line or output with its time.
JudgementFacts and guesses are mixed.Guesses are marked. Says what the fingerprint proves and not.Also says what you did not test.
Safe handlingRuns or extracts before checking.Checks the fingerprint, lists, extracts into an empty folder, runs nothing.Gives a reason for each step.
Fix and next stepsWrong modes, or no order.Key 600, script 750, no SUID. Evidence, then access, then clean-up.Each step has a reason and an owner.
WritingOver a page, or unclear without the commands.One page. Three-sentence summary Dana can act on. No blame.A non-specialist can decide from the summary.

Meets the standard in every row: you can show this report as a work sample. Remove names and data that are not yours to share.

This report shows your work on this scenario, on your own machine, without a proctor. It does not show work on a real system or under time pressure.

Get a result link

When all 15 answers above are right, the server can check them again and give you a signed link. You can put the link in a CV or send it to a manager: it opens a page that shows the course, the test, the date and the name you give here. No account, and nothing is stored: keep the link.