Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Practice library / Penetration testing, first steps

Workbook · Easy · 3 hours

The Penetration Testing Process

Full pentest lifecycle: recon → scan → exploit → post-exploit → report.

  • pentest-lifecycle
  • reconnaissance
  • exploitation
  • post-exploitation
  • reporting
On this page 5 sections
  1. ·About This Workbook
  2. ·Chapter 1 — Pre-Engagement
  3. ·Chapter 2 — Intelligence Gathering, Threat Modelling and Vulnerability Analysis
  4. ·Chapter 3 — Exploitation and Foothold
  5. ·Chapter 4 — Post-Exploitation and Reporting

Before you start

A penetration test is far more than running exploits. The work is a seven-phase process defined by PTES, and each phase has its own output, its own risks and its own paperwork. This workbook walks through the whole lifecycle, from the first call with a client to the delivered report two weeks later. It covers scoping and rules of engagement, passive and active reconnaissance, threat modelling, exploitation, post-exploitation and clean-up, and the writing of findings that link each flaw to business risk. The goal is not just to teach the phases, but to show how they connect, so a tester finishes an engagement with an outcome a client can act on and a trail that will survive a legal review.

What You'll Learn

  • Name the seven PTES phases and say what each phase delivers
  • Write a scope statement and rules of engagement that protect the tester and the client
  • Run passive and active enumeration and record the results as evidence
  • Turn enumeration results into a ranked list of attack paths (threat model)
  • Choose the lowest-impact way to prove a vulnerability and stop at the agreed limit
  • State the goals of post-exploitation and clean up after a test
  • Write a report that links each finding to business risk
  • Plan the timeline and deliverables of a two-week engagement

About This Workbook

A penetration test is a controlled, authorised attack that ends with a report. The attack part is short. The process around it is what makes the test legal, safe and useful.

This workbook follows the Penetration Testing Execution Standard (PTES). PTES has seven phases:

#PhaseMain output
1Pre-engagement interactionsSigned scope and rules of engagement
2Intelligence gatheringMap of the target: names, hosts, services
3Threat modellingRanked list of likely attack paths
4Vulnerability analysisList of confirmed or probable weaknesses
5ExploitationProof that a weakness can be used
6Post-exploitationMeasured impact and a list of changes to undo
7ReportingA report for management and a report for engineers

The four chapters group these phases: chapter 1 is phase 1, chapter 2 is phases 2 to 4, chapter 3 is phase 5, chapter 4 is phases 6 and 7.

Authorised scope only. Every command in this workbook runs against a system that you own or have written permission to test. Use your own lab VM, or a public test target such as Metasploitable, DVWA or a HackMyVM machine. The examples use 10.0.0.5 for the lab VM, and the scan output is an example from a Metasploitable 2 machine. Replace the address with your own. Never run these commands against a third party. In many countries this is a crime, even if you only scan.

Read Introduction to Penetration Testing first. For the detail of phase 1, see Pre-Engagement & Setting Up. For the weakness side of phase 4, see Vulnerability Assessment.

Chapter 1 — Pre-Engagement

Objectives

  • Explain why a test needs written permission
  • Write a scope statement with in-scope and out-of-scope items
  • List the parts of the rules of engagement
  • Build a timeline for a two-week test

Explanation

Pre-engagement is everything that happens before the first packet. A tester who skips it has no legal protection and no way to know when the test is finished.

Written permission. The client signs a document that gives you the right to test. The signer must own the systems, or have the authority to give permission. A cloud provider or a hosting company may also need to approve the test. Keep the signed copy with you during the test. If a guard or an administrator stops you, this paper is your proof.

Scope. The scope says what you may test. Be exact. "The company network" is not a scope. These are scopes:

  • In scope: 10.20.0.0/24 (office network), app.example.com, api.example.com
  • Out of scope: 10.20.1.0/24 (payment systems), all third-party services (mail provider, CDN), social engineering of staff
  • Test window: Monday to Friday, 19:00 to 06:00
  • Source address of the tester: 203.0.113.15

Ask the client who owns each address. An address that belongs to a hosting company is not the client's to give.

Rules of engagement (RoE). The RoE says how you test. It has at least these parts:

PartExample
Allowed techniquesScanning, exploitation of web flaws, password guessing with a limit of 3 tries per account
Forbidden techniquesDenial of service, deleting data, physical entry
Emergency contactName and 24-hour phone number of the client contact
Stop ruleStop and call if you find signs of a real attacker, or if a system fails
Data handlingEvidence is encrypted, kept for 90 days, then deleted
Report deliveryEncrypted file, to named people only

Goals. Agree on what "success" means. A goal such as "show if an outsider can read customer records" is better than "find all bugs". The goal sets the depth of the test and the stop point of the exploitation phase.

Test types. The amount of knowledge you get changes the work.

TypeWhat the tester knowsUse
Black boxOnly the company name or the domainShows what an outsider can find
Grey boxA normal user account and some documentsMost common; saves time
White boxSource code, diagrams, admin accessDeepest review in the time you have

Worked example

A client asks for a test of its web shop. The tester writes this scope statement and sends it for signature.

ENGAGEMENT: Web shop test                       Ref: PT-2026-014
Client contact: IT manager (phone in RoE annex)
In scope:     shop.example.com (203.0.113.40), api.example.com (203.0.113.41)
Out of scope: pay.example.com (payment provider), mail, DNS provider, staff
Type:         Grey box: 2 test accounts provided (customer, support agent)
Window:       2026-12-01 to 2026-12-12, 19:00-06:00 local time
Source IP:    203.0.113.15 (tester)
Forbidden:    DoS, data deletion, mass password guessing, real payment tests
Stop rule:    Stop and call the contact on any sign of an earlier compromise
Goal:         Show if a customer can read another customer's orders

Check the statement for gaps. The payment provider is out of scope, and the test must not send real payment data. The goal is one clear sentence. The window is at night, so the client's team can watch the traffic and the shop has less load.

The tester also builds a timeline for the 10 working days:

DaysPhaseDeliverable
0 (before)Pre-engagementSigned scope and RoE
1Intelligence gatheringAsset list
2Threat modelling and vulnerability analysisAttack-path list
3 to 6Exploitation and post-exploitationEvidence folder, daily note to client
7 to 8ReportingDraft report
9Review with the clientFindings walkthrough
10Final report and clean-upFinal report, list of removed test data

Plan the report as a phase. Beginners often spend most of the engagement on attacks and little time on the report. The report is the product. Reserve at least 30 per cent of the time for it.

Practice questions

  1. Why must the person who signs the permission own the systems?
  2. A client says: "Test everything on example.com." What is wrong with this scope, and what do you ask?
  3. Name two items of the rules of engagement that protect the client from harm.
  4. In which test type do you spend the least time on discovery, and why?
Answers
  1. A person who does not own a system cannot give legal permission to attack it. Without valid permission, the test can be a crime.
  2. "Everything" includes subdomains that may belong to other companies, and systems that are fragile. Ask for a list of addresses and names, who owns each one, and which ones are out of scope.
  3. Examples: the forbidden techniques (no denial of service, no data deletion), the stop rule, the test window, and the limit on password tries.
  4. White box. The tester already has diagrams, code and access, so discovery is short and the time goes to review.

Chapter 2 — Intelligence Gathering, Threat Modelling and Vulnerability Analysis

Objectives

  • Separate passive from active reconnaissance
  • Run basic enumeration commands and save the output
  • Build an asset list from the results
  • Rank attack paths by likelihood and impact
  • Explain the difference between a scan result and a confirmed vulnerability

Explanation

Intelligence gathering builds the map of the target. There are two kinds.

  • Passive reconnaissance does not send traffic to the target. You read public records: DNS data, certificate logs, search engines, job advertisements. The target cannot see it.
  • Active enumeration sends traffic to the target: a scan, a request, a login try. The target can see it, so it must be in scope and in the test window.

A passive example, with the public registration data of a domain:

whois example.com | head -12 dig +short NS example.com dig +short MX example.com

   Domain Name: EXAMPLE.COM
   Registry Domain ID: 2336799_DOMAIN_COM-VRSN
   Registrar: RESERVED-Internet Assigned Numbers Authority
   Updated Date: 2025-08-14T07:01:34Z
   ...
a.iana-servers.net.
b.iana-servers.net.
0 .

The NS lines name the DNS servers. The MX line shows the mail setup. Write each fact in your notes with the date and the command.

Active enumeration starts with a host list, then ports, then services. Use nmap against your lab target. Always save the output in all formats with -oA, so the scan is a piece of evidence.

nmap -sn 10.0.0.0/24 -oA evidence/01-hosts
nmap -sV -sC -p- --min-rate 1000 10.0.0.5 -oA evidence/02-fullscan

The first command finds live hosts without a port scan (-sn). The second scans all 65535 ports (-p-), detects service versions (-sV) and runs the default scripts (-sC). --min-rate 1000 sends at least 1000 packets a second; lower the value if the client's network is fragile.

Starting Nmap 7.94 ( https://nmap.org ) at 2026-12-01 19:12 UTC
Nmap scan report for 10.0.0.5
Host is up (0.00040s latency).
Not shown: 65530 closed tcp ports (reset)
PORT     STATE SERVICE VERSION
21/tcp   open  ftp     vsftpd 2.3.4
22/tcp   open  ssh     OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)
80/tcp   open  http    Apache httpd 2.2.8 ((Ubuntu) DAV/2)
|_http-title: Metasploitable2 - Linux
3306/tcp open  mysql   MySQL 5.0.51a-3ubuntu5
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

Hardly any of this output is a vulnerability yet. It is a list of services with versions. Each line is a lead for the next phase. See Nmap Scanning to practise, and Web Recon and OSINT Recon for the web and public-data side. The workbook OSINT & Reconnaissance has the theory.

Threat modelling turns the asset list into a plan. Ask two questions for each asset: how likely is an attack, and how bad is the result? Rank the attack paths. Put effort where the goal of the test is.

AssetLeadLikelihoodImpactRank
10.0.0.5:21Old FTP versionHighMedium2
10.0.0.5:80Old web server with a login pageHighHigh1
10.0.0.5:3306Database open to the networkMediumHigh3
10.0.0.5:22Old SSH, password loginLowHigh4

Vulnerability analysis checks each lead. A scanner or a version string says that a weakness is possible. You must validate it. A validated weakness is a finding. A scanner line that you did not check is a rumour.

searchsploit vsftpd 2.3.4

------------------------------------------------- ---------------------------------
 Exploit Title                                   |  Path
------------------------------------------------- ---------------------------------
vsftpd 2.3.4 - Backdoor Command Execution        | unix/remote/49757.py
------------------------------------------------- ---------------------------------

searchsploit searches the local copy of Exploit-DB. A hit tells you that a public record exists. It does not tell you that your target is affected: the target may use a patched build with the same version string. In phase 5 you confirm it in the safest way you can.

Worked example

You test the lab VM 10.0.0.5 and you want the ranked list for phase 5.

  1. Run the host scan and the full scan with -oA. Keep the files.
  2. Open the web page with curl -I http://10.0.0.5/ and note the Server header.
  3. Write one row per open port in the threat model table.
  4. For each high-rank row, find the source of the claim (a vendor advisory or Exploit-DB) and write its identifier.
  5. Mark each row validated, not validated or not affected. At this point all rows are not validated.

curl -I http://10.0.0.5/

HTTP/1.1 200 OK
Date: Tue, 01 Dec 2026 19:20:41 GMT
Server: Apache/2.2.8 (Ubuntu) DAV/2
X-Powered-By: PHP/5.2.4-2ubuntu5.10
Content-Type: text/html

The headers confirm the Nmap result and add the PHP version. The old PHP and Apache versions raise the web row to rank 1. You have not exploited anything. You only collected facts.

Practice questions

  1. Which of these are passive: a dig query to a public DNS resolver, a nmap -sV scan of the target, reading the target's job advertisements?
  2. Why do you save every scan with -oA?
  3. A scanner reports "Apache 2.2.8 is vulnerable to CVE-XXXX". Why is this not yet a finding?
  4. In the threat model, why does the database on port 3306 rank below the web server even though the impact is high?
Answers
  1. The dig query to a public resolver and the job advertisements are passive: no packets reach the target. The nmap -sV scan is active.
  2. The saved files prove what you found and when. They also let you compare scans, show the client what you did, and build the report without a second scan.
  3. The scanner only compared a version string with a database. The vendor may have patched the build, or the feature may be off. A finding needs validation.
  4. The rank combines likelihood and impact. In this example the web server is more likely to be reached and attacked, and it is closer to the goal of the test. The database ranks third because it is less likely to be used first.

Chapter 3 — Exploitation and Foothold

Objectives

  • State the purpose of exploitation in a professional test
  • Choose the lowest-impact proof for a weakness
  • Record evidence in a way that others can repeat
  • Decide when to stop and call the client

Explanation

Exploitation answers one question: can this weakness be used to break the goal of the test? It is not a contest to get the most shells. A tester proves a risk. The client must be able to understand the proof and repeat it.

Choose the lowest-impact proof. Several actions can prove the same flaw. Take the one that does the least harm.

WeaknessHigh-impact proofLowest-impact proof
SQL injectionDump the full customer tableRead the database version string or one test row
Weak passwordLog in to the admin account of the production shopLog in to a test account that the client created
Remote code executionOpen a full shell and browse filesRun id and hostname, save the output, close the session
Path traversalDownload the configuration with passwordsRead a harmless file such as /etc/hostname

Check before you act. Ask these questions before each attempt:

  1. Is the target in scope and inside the test window?
  2. Does the RoE allow this technique?
  3. Can this action crash the service? If yes, did the client accept this risk?
  4. Do I know how to undo it?

If one answer is "no" or "I do not know", stop and ask.

Record while you work. Log every attempt, successful or not: time (UTC), source address, target, command, result. You need this log for three reasons. The client can compare it with their own logs. You can answer "was that you?" at 03:00. The report needs the exact steps.

2026-12-02 20:41:07Z  src 203.0.113.15  dst 10.0.0.5:80
Action:  GET /login.php?user=test'  (single quote in the user field)
Result:  PHP error page shows the SQL query text
Meaning: input reaches the database query without escaping (candidate SQL injection)
Next:    validate with one harmless request, then stop. Do not dump data.

Foothold and stability. A foothold is the first position inside the target, for example a shell as a web server user. Keep it stable but small. Do not leave tools running that the client does not know about. Write down each file you create or change, because you must remove it later.

Stop points. Stop the exploitation phase when one of these happens:

  • You reach the goal. Prove it once, and move on.
  • You meet a system or data that is out of scope.
  • A service becomes unstable.
  • You see signs that another attacker was there before you. Call the emergency contact. This is now an incident, and the Incident Handling process starts.

Never test a weakness against a live system without a plan to undo it. A single bad request can lock accounts or stop a service. Test on the lab copy first, if one exists.

For hands-on exploitation of a lab target, see the lab Metasploit Basics. It uses a machine that you run yourself. This workbook does not repeat the commands.

Worked example

You tested the single quote on a login form. The page shows an SQL error. You validate the flaw with the lowest-impact proof. Use a lab target such as DVWA, where this flaw is expected.

curl -s "http://10.0.0.5/dvwa/vulnerabilities/sqli/?id=1%27&Submit=Submit" \
  -b "security=low; PHPSESSID=abc123" | head -5
You have an error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near ''1''' at line 1

The error shows that the quote broke the query. Now you write down the result and stop at this point. You do not extract the user table. The one error message and the request are the proof. Your note reads:

FieldValue
FindingSQL injection in parameter id
EvidenceRequest and error text, saved to evidence/05-sqli-error.txt
Impact shownInput reaches the database query
Impact not testedData extraction (out of the agreed goal for this host)
Undo neededNone; the request changed no data

The decision to stop is part of the skill. The client gets a validated finding, no data leaves the network, and the system stays up.

Practice questions

  1. What is the difference between "find a vulnerability" and "exploit a vulnerability" in a test report?
  2. Give the lowest-impact proof for a path traversal flaw on a production server.
  3. You find a web shell on the server that you did not upload. What do you do?
  4. Why do you log failed attempts too?
Answers
  1. "Find" means the weakness is present or probable. "Exploit" means that you used it and have evidence. The report must say which one each finding is.
  2. Read a harmless file such as /etc/hostname, save the request and the response, and stop. Do not read files with passwords or customer data.
  3. Stop the exploitation work and call the emergency contact. A web shell that you did not put there means an earlier attacker. The client must start an incident response.
  4. Failed attempts also appear in the client's logs. The log lets you show that an alert was caused by the test, and it shows which defences blocked you. That is useful for the report.

Chapter 4 — Post-Exploitation and Reporting

Objectives

  • State the goals of post-exploitation in a professional test
  • Measure the impact of a foothold within the rules
  • Clean up every change made during the test
  • Write an executive summary and a technical finding
  • Rate a finding by risk, not only by technical severity

Explanation

Post-exploitation starts after a foothold. Its goal is not to cause damage. Its goal is to answer: what could a real attacker reach from here, and what would that cost the client? Typical questions:

  • What privileges does this account have? Can it become administrator?
  • What data can this account read? Is it sensitive?
  • Can it reach other systems (lateral movement)?
  • Would the monitoring see it?

Stay inside the agreed goal. If the goal is "read another customer's orders", you do not need to reach the domain controller. When the RoE allows deeper work, go step by step and note each step.

A basic check of the rights of a foothold on a Linux lab VM:

id sudo -l find / -perm -4000 -type f 2>/dev/null

uid=33(www-data) gid=33(www-data) groups=33(www-data)
Sorry, user www-data may not run sudo on metasploitable.
/bin/mount
/bin/umount
/usr/bin/passwd
/usr/bin/sudo

id shows who you are. sudo -l lists the commands you may run as another user. The find command lists files with the setuid bit: a file that runs with the rights of its owner, which is a common path to higher rights when it is misconfigured. The listing is a lead, not a result. For the full method, see the lab Privilege Escalation and Windows Privilege Escalation.

Impact, not trophies. A statement such as "I read /etc/passwd" means little to a manager. "A customer could read the orders of 40,000 other customers" is clear. Measure impact in business terms: data, money, trust, law.

Clean-up. Before the test ends, undo what you changed.

  1. List every file, account, scheduled job and setting that you created (from your log).
  2. Remove them, or ask the client to remove them.
  3. Check that each removal worked, and write the result.
  4. Give the client a list so that they can search their logs for your actions.

Reporting. The report is the main deliverable. A good report has two readers: the manager who decides, and the engineer who fixes. It usually has these parts:

PartReaderContent
Executive summaryManagementOne page: the goal, the result, the top risks, the main advice, in plain words
Scope and methodEveryoneWhat was tested, when, how, with limits
FindingsEngineersOne entry per finding (below)
AppendixEngineersScan output, evidence files, tool versions

One finding entry has these fields: title, risk rating, affected asset, description, steps to reproduce, evidence, impact, and a recommendation that someone can follow. The rating combines likelihood and impact. A technically simple flaw that exposes customer data is high risk. A complex flaw on an isolated test server can be low risk. See Documentation & Reporting for layout and tools.

After delivery, offer a retest: check again that the fixes work. A test that ends with the PDF has not closed the risk.

Worked example

The finding from chapter 3 becomes this entry in the report.

F-01  SQL injection in the order search            Risk: HIGH
Asset:      shop.example.com /orders/search  (parameter: q)
Description:
  The parameter q is placed into an SQL query without parameter binding.
  A single quote returns the database error text.
Steps to reproduce:
  1. Sign in as the test customer account.
  2. Send: GET /orders/search?q=%27
  3. The response contains the text "You have an error in your SQL syntax".
Evidence:   evidence/05-sqli-error.txt (request and response, 2026-12-02 20:41 UTC)
Impact:     An attacker with any customer account can probably read the orders
            of other customers. Data extraction was not tested (out of agreed scope).
Recommendation:
  Use prepared statements for every query that takes user input.
  Hide database error text from users.
  Retest after the fix.

The executive summary of the same engagement is short.

We tested the web shop for 10 days. The goal was to find out if one customer can read the data of another. We found one path that is very likely to allow it (finding F-01). The shop also shows detailed error messages that help an attacker (F-02). The other tested areas resisted the attacks. We advise that the team fix F-01 first, then retest.

Note the rules: plain words, the goal first, the result next, one clear action.

Practice questions

  1. What is the goal of post-exploitation in a professional test?
  2. Name three kinds of items that you list for the clean-up.
  3. A finding is technically complex but exposes all customer records. Is the risk low or high? Why?
  4. Why does a report need an executive summary that is separate from the findings?
  5. Write the "Recommendation" line for a finding "Admin panel reachable from the internet with a default password".
Answers
  1. To measure what an attacker could reach from the foothold, and the business impact of it. The goal is not to cause damage or to collect trophies.
  2. Files, accounts, scheduled jobs, and changed settings. Test data in the application also belongs on the list.
  3. High. Risk is likelihood and impact, and the impact is large. Complexity lowers the likelihood a little, but data of all customers is a severe impact.
  4. Managers decide on money and priority and read little. They need the result and the advice in plain words. Engineers need the detail to reproduce and fix.
  5. Example: "Remove the admin panel from the internet or restrict it to the VPN address range. Change the default password at once, and enable multi-factor sign-in."

Next. Put the process into practice in the labs: Nmap Scanning, then Metasploit Basics, then Privilege Escalation. After each lab, write one finding entry in the format of chapter 4.

Sign in to track progress and send feedback.

Related