Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Penetration Testing Basics

The whole lesson is free and interactive. Read it here, or press Start lab to run it for real in a live lab, with no account needed.

Container lab8 min read5 commands

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

Permission first, then the scan

A college has asked for a test of its network. Three of its hosts are in the written scope. A fourth, on the same network, belongs to an outside supplier, and the college cannot give permission for it. A penetration test starts by knowing which is which.

The one rule

Warning

This lab is a network that is insecure on purpose. Test the three hosts in scope in your own private copy, and nothing else. Never test a system without written permission from its owner: in the UK that can be a crime under the Computer Misuse Act 1990.

By the end of this lesson

Note

I can scan the hosts in a written scope and leave the others alone.

Key words

  • Scope: the systems a test may touch.
  • Out of scope: a system the test must leave alone.
  • Port: a numbered door where a service listens.
  • Banner: what a service says about itself.
  • Log: the record a server keeps of what reached it.

Starter: what you already know

Note

Answer in your head. 1. What does a port scan find? 2. Who can give permission to test a computer? 3. What does a web server send before the page? Answers: the services listening; its owner; headers.

Before you start

Note

Press Start the lab on the bar at the top of this lesson and wait until it says it is running. The scanner runs as an ordinary account, so it uses a connect scan, -sT. Each Run button below types its command into your lab's terminal, one after another in the same session. To watch them, or to type your own, press Open terminal on the bar.

1. The supplier's log, before anything

hr writes a line for every connection it receives. Right now it holds only the line it wrote when it started. At the end of the lesson it should still hold only that line.

Command
docker logs hr

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

2. Every port on the three hosts in scope

Nmap tries all 65,535 ports on www, intranet and cache, naming only those three. It finds 8080 open on www, 8000 on intranet and 6379 on cache. A default scan of 1,000 ports would have missed the cache's.

Command
docker exec scanner nmap -sT -Pn -p- --open www intranet cache

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

3. A banner is a claim

The site's Server header says Apache/2.4.49 (Unix). That version had a known, serious flaw, so a tester writes it down and checks it before trusting it. In fact the site is a small Python server: the module shows how to prove that without harming anything.

Command
curl -sI http://www:8080/

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

4. The defenders can see you

The site keeps a log, and the first command leaves out its own health checks. The scan is a connection that closed early, from the scanner's address, and your request is HEAD /. This is how a defender spots a test, and why a real one tells them when it will run.

Command
docker logs www 2>&1 | grep -v 127.0.0.1

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Command
docker logs hr

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

A common mistake

Warning

Many people think anything they can reach on a network is theirs to test. Reaching a host is not permission to test it. The supplier's gateway is one connection away, and only the supplier could allow a test of it.

Exit check

Tip

Answer without looking back. 1. Which host is out of scope? 2. Which port is open on the cache? 3. What does the site's banner claim? 4. What should hr's log hold at the end? Answers: hr; 6379; Apache 2.4.49; only its start line.

For teachers

Tip

This lesson is a small example of a lesson worked in a lab: the steps and the Run buttons are the lesson, and the lab is each student's own copy. The lab holds a scanner, three hosts in scope and one out, and nothing here marks itself: the student hands in a short report. The module Penetration testing methodology goes further: the written agreement and the law, reconnaissance, version detection, validating each finding with the least intrusive check, the report and the retest. Key learning points: 1. A test touches only the hosts in scope. 2. A full scan finds ports a default scan misses. 3. A banner is a claim. Common mistake: thinking reachable means allowed. Equipment: the lab and its terminal. Tip: before step 4, ask students what the site's log will show about them. Copy it into your own module and change it, or build one from scratch with the Lab menu in the lesson builder.

Teaching a class? Set these lessons for your students with marking and a lab for every student.