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

Free lesson

Scope, permission and the law

After this lesson: I can check that a target is inside a written scope before I touch it.

55 min lesson3 commandsPenetration testing lab: from scope to retest

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

Already have an account? Sign in

Test everything you can reach?

Fernbrook College asks you to test its network. On the same network sits a payroll gateway that an outside company runs.

The college's IT manager says: "Test everything you can reach." Should you? This lesson answers that before any scan starts.

The one rule

Warning

Test only your own lab copy. Testing a real system needs written permission from someone entitled to give it. Without it, getting into a computer can be a crime: in the UK under the Computer Misuse Act 1990.

Quick check: the rule

Have a go

Quick check: the rule

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

By the end of this lesson

Note

I can check that a target is inside a written scope before I touch it.

Key words

WordWhat it meansExample
Penetration testan attack on a system, with permission, to find weaknesses
Scopethe systems a test may touch
Out of scopea system the test must leave alonehr
Authorisationwritten permission from the system's owner
Rules of engagementhow, when and with what the test may run

The cells students fill in are left blank in this preview.

Starter

Have a go

Starter

4 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Permission has to come from the owner

The Computer Misuse Act 1990 makes it an offence to access a computer without authorisation (section 1). It is another to impair how one works (section 3).

Authorisation must come from someone entitled to control that system. A college can let you test its own servers. It cannot let you test a supplier's gateway, even on its network.

What a written authorisation holds

PartWhat it says
WhoThe client, the tester, and a signer with authority over each system
WhatThe hosts in scope, and the hosts out of scope, by name or address
WhenThe dates and hours the test may run
HowWhat is allowed, and what is not: no denial of service, no copying data
ContactsWho to call, and when to stop and call them
EvidenceHow findings are kept, and when they are deleted

The cells students fill in are left blank in this preview.

Check

Have a go

Check

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Fernbrook's scope, written down

The college signed for three hosts: www (its public site), intranet (the staff portal) and cache (the portal's session store). The gateway, hr, is out of scope.

You may sign in once with each known default and use your own account, tester. You may not change or copy data. The next Run writes the scope as a file.

Write the scope as a file

Command
printf 'www\nintranet\ncache\n' > scope.txt

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

List the targets, sending them nothing

Command
docker exec -i scanner nmap -sL -iL - < scope.txt

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

A list scan only looks the names up

-sL asks for the address of each name and stops there, so it says "0 hosts up". -iL - reads the targets from the file, so only the scope is on the list.

The gateway keeps its own log of every connection. Read it now: it should hold only the line it wrote when it started.

Read the supplier's log

Command
docker logs hr

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

Check

Have a go

Check

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Try it: check a target against the scope

Code: python
# The written scope, and the hosts somebody wants to test.
scope = {"hosts": ["www", "intranet", "cache"], "exclude": ["hr"]}
asked = ["www", "cache", "hr", "printer"]

for host in asked:
    if host in scope["exclude"]:
        print(host, "is out of scope: never touch it")
    elif host in scope["hosts"]:
        print(host, "is in scope")
    else:
        print(host, "is not in the agreement: ask before you touch it")

# Add "intranet" to the asked list and press Run again.

Make a free account to save your work and track your progress.

A common mistake

Warning

Many people think permission from whoever asks for the test is enough. It is enough only for systems that person controls. The IT manager controls www, intranet and cache, so the gateway needs the supplier's own written permission, or it stays out.

Stop, call, and let the defenders know

Stop and call the contact if a test could harm a service, or you find signs of a real attacker. The agreement says who.

The client's defenders are told the window and your address. Then their logs show a test they expected, not an attack. Lesson 2 reads those logs.

Assignment: check an engagement before it starts

An engagement is a dictionary such as {"signed_by": "a.khan", "owners": ["a.khan"], "scope": {"hosts": ["www"], "exclude": ["hr"]}, "start": "2026-11-23T09:00", "end": "2026-11-23T17:00"}. Write three functions.

in_scope(host, scope) is True only when the host, ignoring case and spaces at either end, is in scope["hosts"] and not in scope["exclude"]. in_window(when, start, end) is True when start <= when < end; every time is written YYYY-MM-DDTHH:MM. problems(engagement, when) returns a list of these strings, in this order, for each that applies: "not signed" (an empty signed_by), "signer cannot authorise" (signed, but not by one of owners), "no hosts in scope", "outside window".

Code: python
def in_scope(host, scope):
    return True


def in_window(when, start, end):
    return True


def problems(engagement, when):
    return []

Make a free account to save your work and track your progress.

Exit quiz

Have a go

Exit quiz

5 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.