Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 37 ยท Getting Started

Scope, Law and Building a Safe Lab

Before you run a single Metasploit command: understand authorization, scope and rules of engagement, and plan an isolated lab network so practice stays legal and safe.

The most important Metasploit skill is knowing when not to use it. The same command is a professional service on a client's test server with a signed agreement and a crime on a stranger's server. Law does not care that you were "just looking" or that you meant well.

This lesson covers the paperwork that makes testing legal, and how to build a lab where you can practice freely without touching anyone else's systems.

This is general education, not legal advice. Computer-misuse laws differ by country; if in doubt, ask a lawyer before testing anything that is not yours.

Authorization, scope and rules of engagement

A professional test starts with a written agreement. It normally contains:

  • Authorization. Who owns the systems and who allows testing, signed by someone with the authority to do so. A cloud or hosting provider may need to approve separately.
  • Scope. Exactly which IP ranges, hostnames, applications and time windows are included, and what is out of scope (third-party services, production databases, other tenants).
  • Rules of engagement. What is allowed: denial-of-service tests or not, social engineering or not, how to treat found data, contact details if something breaks.
  • Reporting and data handling. How findings are delivered, how long evidence is kept and how it is destroyed.

If a target is not listed, you do not test it, even if it is next to a listed one. If a scan shows a neighbour host that is out of scope, you note it and stop.

Before you test

Written permission Signed by the owner.
Clear scope Ranges, hosts, dates.
Rules What is allowed and what is not.
Contacts Who to call if something breaks.

No paper, no packets.

1 / 2

What a safe home lab looks like

You never need to test a real server to learn. A lab has three parts.

  1. An attacker machine. A Linux virtual machine with your tools. Security distributions such as Kali Linux ship Metasploit preinstalled; you can also install it on any Linux, macOS or Windows host.
  2. One or more deliberately vulnerable targets. Virtual machines made for practice, such as intentionally vulnerable appliances published for training, or old operating-system images you keep offline. Only download them from the project's official page.
  3. An isolated virtual network. In your virtualization software, put every lab machine on a host-only or internal network. The targets then cannot reach the internet and your home network cannot reach them.
flowchart LR
    subgraph Lab["Host-only lab network 10.10.10.0/24"]
        A["Attacker VM 10.10.10.5"]
        T1["Practice target 10.10.10.20"]
        T2["Practice target 10.10.10.21"]
    end
    A --> T1
    A --> T2
    Lab -. "no route" .- N["Internet / home network"]

Vulnerable machines must never share a network with things you care about, because anything else on the segment can reach them as well.

Use snapshots: take one of each target in its clean state, so after every experiment you can restore it in seconds. Snapshots also let you try the same technique twice and compare logs.

Checking that an address is in scope

Good testers build the scope check into their tools. Real scanners can take an allow-list and refuse other targets. The stand-in below shows the idea with Python's ipaddress module: it checks whether an address belongs to the lab range before anything else is done. Run it with the sample addresses.

Python Scope check before testing

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Anything outside the lab range is rejected. Real engagements use the same principle, with the exact list from the contract.

Keeping a test log

Write down what you did and when: start time, targets, commands, results. In a professional job the log protects you (it proves you stayed in scope) and helps the client match your activity against their alerts. Metasploit can record console sessions to a file; the next lessons show how. Even in your lab, practicing note-taking now builds a habit you will need later.

Python A tiny timestamped test log

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Responsible behaviour

  • Stop and report if you find data you were not expecting (personal records, credentials of real people).
  • Never leave tools or accounts behind on a client system; clean up what you created.
  • Report vulnerabilities you find to the owner, ideally through their disclosure process, and give them time to fix.
  • Do not run tests that could harm availability unless the rules explicitly allow it.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What makes a penetration test legal?

    Authorization and scope are what separate testing from unauthorized access.
  2. 2. What should you do if a scan reveals a neighbouring host that is out of scope?

    If a host is not in the agreed scope you do not test it.
  3. 3. Which network type isolates lab machines best?

    Host-only or internal networks keep vulnerable machines unreachable from outside.
  4. 4. Why take snapshots of lab targets?

    Snapshots let you roll back in seconds and repeat experiments.

Summary

  • Authorization and scope come first; without them a test is illegal.
  • Rules of engagement say what is allowed, and a contact list says who to call.
  • Build a lab on a host-only network with snapshots of vulnerable targets.
  • Check scope in tooling and keep a timestamped log.

Next: Installing Metasploit and the Database