← Security lab: audit a Pi with Kali

Security lab: audit a Pi with Kali: recap

For after the lessons: one card per lesson, to check what you remember. Answer each question in your head or on paper first, then check it. Nothing here is marked.

The lab

1. The rules of the lab, and your first look

Try firstWhat two things must be true before you test a computer's security?

Check your answer

You own it or have written permission, and the test is contained to the lab.

Security testing is only fair on a computer you own or have written permission to test, and only the ones named on the lab sheet. The lab is cut off from other networks so nothing can leak out. What you find is reported and fixed, not used. Kali is a toolbox of security tools; the target is the computer you may test.

The lab rules on Kali: only the named target, never the school network, write down what you change, report what you find.
The lab rules on Kali: only the named target, never the school network, write down what you change, report what you find.
Open the lesson →

2. What is listening: finding open ports

Try firstWhat does it mean when a scan says a port is open?

Check your answer

A service is listening there. Whether that is a problem depends on the service.

A port is a numbered door on a computer; a service listens behind it. nmap target lists the open ports and what is behind them. Open means listening, not broken into. nmap target > scan1.txt saves the scan as evidence. Filtered means a firewall is not answering.

nmap target lists the ports with a service listening: 21 (ftp), 22 (ssh), 23 (telnet) and 80 (web).
nmap target lists the ports with a service listening: 21 (ftp), 22 (ssh), 23 (telnet) and 80 (web).
Open the lesson →

Audit

3. Old versions and plain text

Try firstWhy is an old version a finding?

Check your answer

It is missing fixes for problems that are public by now.

nmap -sV target asks each open service for its version. Old versions miss fixes for problems that are now public, so an old version is a finding. Some services are findings at any version: telnet sends everything, passwords included, as readable text, and ssh does the same job encrypted.

nmap -sV adds each service's version: OpenSSH 7.2p2, vsftpd 2.0.8 and Apache 2.4.18 are all old.
nmap -sV adds each service's version: OpenSSH 7.2p2, vsftpd 2.0.8 and Apache 2.4.18 are all old.
Open the lesson →

4. What guessing looks like in the log

Try firstWhat pattern in a log says someone is guessing passwords?

Check your answer

Many failed logins for one account from one address in a short time.

Every login attempt is written to /var/log/auth.log. sudo grep Failed shows the failures and grep -c counts them. Many failures for one account from one address in a short time is guessing. The defence is to make guessing pointless or expensive: key login, no root login, limited attempts, long passwords.

On the target, grep -c counts the failed login lines in auth.log: 14 in a short run, all from one address.
On the target, grep -c counts the failed login lines in auth.log: 14 in a short run, all from one address.
Open the lesson →

Fix

5. Close the doors: harden the target

Try firstWhy is upgrading Apache a better fix than just allowing it through the firewall?

Check your answer

The firewall only filters who reaches the door. The old program behind it is still old.

Fixing is layers. Stop services you don't need (sudo systemctl stop name). Upgrade what is old (sudo apt update, sudo apt upgrade). Tighten ssh: PermitRootLogin no and PasswordAuthentication no in /etc/ssh/sshd_config, then sudo systemctl restart ssh. Filter with the firewall: allow only what is needed. Each fix does one job.

On the target, stopping telnet and vsftpd takes their ports off the network: two fewer doors.
On the target, stopping telnet and vsftpd takes their ports off the network: two fewer doors.
Open the lesson →

Audit

6. Challenge: audit, fix and prove it

Try firstName one thing a port scan cannot tell you.

Check your answer

Any of: whether passwords are strong, what the file permissions are, what is inside the files.

An audit is a cycle: scan and save it (nmap -sV target > before.txt), fix (stop, upgrade, tighten, filter), scan again (> after.txt) and compare. A scan sees open ports and versions only, so the report says what it did not check. Absence of findings is not proof of safety.

The 'before' scan saved as evidence. After the fixes you scan again and compare the two.
The 'before' scan saved as evidence. After the fixes you scan again and compare the two.
Open the lesson →