← Teacher guide

What is listening: finding open ports

Every network service listens on a numbered port. A port scan asks each port whether anything answers, and lists what is open and what service is behind it. Open does not mean broken: it means something is listening. Whether that matters depends on what.

Security lab: audit a Pi with Kali · The lab · about 40 minutes · Open the student lesson

Classroom resources

Open these in Waypoints Prepare with one click. To share a file another way, copy its address and paste it into Load URL, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.

Students will be able to

Timing

Predict and Try 8 min · Worked example 10 min · Vary 10 min · Practise and Make 12 min

Before class

Try the boards yourself.

The gate (read first). This course teaches security as audit and defence: you scan, read and fix a lab computer your class owns. The pretend Kali and target in the lessons are safe anywhere. The real-lab version is different, so it needs your sign-off before anyone starts: school policy and IT's agreement, a written lab agreement every student signs (lab-rules.txt on the board is a model), and a lab that is cut off from every other network: a Pi running Kali and a second Pi or a virtual machine as the target, joined by one switch or one ethernet cable, with no router and no internet. Download the Kali image and any tools once, at home or at IT's request. Scan only the target named on the lab sheet. This course does not teach breaking into anything: it stops at find, understand and fix. It relaxes the 'defensive only' rule of the other courses only in that the real lab uses real scanning tools on a computer the class owns.

Simplifications: the pretend nmap supports -sn, -sV (next lesson) and -p, and scans only the target, Kali itself and the lab range. It shows open and filtered only. A real nmap has many more options and is very noisy on a real network: that is why the lab is isolated.

Real lab, if you run one: Kali Linux has a Raspberry Pi image (Pi 4 or Pi 5; the Pi 5 wants its 27 W supply); flash it with Raspberry Pi Imager or the Kali image instructions and boot it with a screen and keyboard, or ssh in. The target can be a second Pi (an older Raspberry Pi OS with a few extra services) or a purpose-made practice target your IT team approves. Start from the same state every time: re-flash, or snapshot a virtual machine. nmap is already on Kali. Give each pair a printed lab sheet naming the target's address, the one account they may use and what they are allowed to change.

Other options: netstat or ss -tln (run on the target) list its own open ports, the defender's view of the same thing; masscan and others scan faster, with the same permission rules.

Running the lesson

  1. Predict: wrong answers think a scan sees inside.
  2. Try: ask which ports and services the class found.
  3. Worked example: stop at Sam's mistake and ask what open means.
  4. Vary: ask why Kali has nothing open.
  5. Make: ask what a report is without evidence.

In class

On the slides at these points. Students can do the whole lesson on their own; these are for the room. In the deck, the Run, Modify and Make slides have the live playground in them (the tutorial link is the backup), and the notes above are in each slide's speaker notes.

The hard part (on purpose)

Open versus broken. Students expect red alarms; a scan only reports what is listening.

When students get stuck

What you will seeA question to askThe fix
A student's nmap says 'not on the lab sheet'.Which address did you scan?Only target or 10.0.0.2.
A student thinks open ports mean a break-in.What is a web server doing?Listening on 80 on purpose.

Answers to the checks

  1. what a scan shows: You scan the target with nmap target. What does the scan list?
    Which ports are open and what service is behind each. A scan sees the doors, not what is inside.
  2. Try: scan the target: Scan the target with nmap target. Which ports are open?

    nmap target lists four open ports on the target: 21, 22, 23 and 80.
  3. Reading a scan: The scan shows 23/tcp open telnet. What does that tell you?
    A telnet service is listening on port 23
    Open means a service is listening. Whether that is a problem depends on the service.
  4. Find the mistake: Sam reads the scan. Click the line where it first goes wrong.
    line 2
    Line 2: an open port only means something is listening, as a web server should. The question is whether each one is needed and safe.
  5. Which port: Which port number is ssh, the way administrators log in?
    22
    ssh is 22. Web is 80 (and 443 for secure web), ftp is 21, telnet is 23.
  6. One port: Scan only the ssh port on the target: nmap -p 22 target.

    -p 22 limits the scan to one port.
  7. Who is here?: Find every computer on the lab network with nmap -sn 10.0.0.0/24.

    -sn means find the computers without scanning ports: Kali and the target.
  8. Scan yourself: Scan Kali itself: nmap localhost. What is listening?

    Nothing: a fresh Kali offers no services. The fewer services, the fewer doors.
  9. Filtered: A scan shows 22/tcp filtered instead of open. What does that mean?
    A firewall is blocking the answer
    Filtered: something, usually a firewall, is dropping the knock.
  10. The web port: Which port would you expect a web server on?
    80
    80 is plain web pages.
  11. Review: findings: Review: you find a weakness on the target. What do you do?
    Report it and fix it
    Find, report, fix.
  12. keep the evidence: Scan the target and save the result in a file called scan1.txt.

    nmap target > scan1.txt saves the scan. It is your 'before' evidence for the report.

Solutions

One possible solution for each task. Other correct programs are fine.

Vary: change one thing › One port

Open task: any program that does what the step asks.

Vary: change one thing › Who is here?

Open task: any program that does what the step asks.

Vary: change one thing › Scan yourself

Open task: any program that does what the step asks.

keep the evidence

Open task: any program that does what the step asks.

Stretch and support

Stretch: Find out what the 1000 'most common ports' are and why a default scan only checks those.

Support: A card of ports: 21 ftp, 22 ssh, 23 telnet, 80 web.

Exit ticket

What does it mean when a scan says a port is open?

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

What each step is for

Where it leads

Links: Security and privacy › Names and addresses; Networks; next: Old versions and plain text.