TExcelTAD
Home › Ethical Hacking & Penetration Testing Methodology › Penetration Testing Exercises

Penetration Testing Exercises

These exercises cover the whole course, in the order of an engagement. Each names the lesson it practises; try it before opening the answer. The scenario is the same throughout: an authorised internal and external test of Lab Retail Ltd, scope 10.10.0.0/24 minus 10.10.0.1 and 10.10.0.200/29, names under lab.test, window 2026-12-01 to 2026-12-12, 08:00–17:00 UTC. The usual rule applies to anything you learn here: test only systems you own or are authorised to test (Authorization, Scope and Rules of Engagement).

Exercise 1: which service?

The client's CISO asks: "Our auditors want proof that our external perimeter was tested this year, and I want to know whether our SOC would notice a real attacker." Which service or services do you propose? Lesson: What a Penetration Test Is.

Answer

Two questions, two services: an external penetration test (with a report and retest the auditors can read) for the first; for the second, a purple-team exercise or, with enough time and board-level authorization, a red-team exercise. The penetration test can also record which steps the SOC detected, if the blue team is announced, but that only partly answers the second question.

Exercise 2: paperwork

List the documents that must exist and be signed before the first packet, and say which one answers each of: may we test, what may we test, how may we test, who holds liability. Lessons: Written Authorization, Contracts and Insurance, The Rules of Engagement Document.

Answer

May: the authorization to test (signed by someone with authority over the systems). What: the scope document. How: the rules of engagement. Liability: the MSA (limitation of liability, indemnities) and the tester's insurance. Also: SOW, NDA, DPA if personal data may be seen, third-party consents for hosted assets.

Exercise 3: scope arithmetic

Which of these may be tested: 10.10.0.0, 10.10.0.1, 10.10.0.199, 10.10.0.207, 10.10.0.208, 10.10.1.10, and shop.lab.test resolving to 10.10.0.30 and 203.0.113.50? Check your answer with the code. Lesson: Scope as Data.

python · try it yourself
import ipaddress
scope = [ipaddress.ip_network("10.10.0.0/24")]
excluded = [ipaddress.ip_network("10.10.0.1/32"), ipaddress.ip_network("10.10.0.200/29")]
def ok(a):
    ip = ipaddress.ip_address(a)
    return any(ip in n for n in scope) and not any(ip in n for n in excluded)
for a in ["10.10.0.0", "10.10.0.1", "10.10.0.199", "10.10.0.207", "10.10.0.208", "10.10.1.10"]:
    print(f"{a:<12} {'in scope' if ok(a) else 'OUT'}")
shop = ["10.10.0.30", "203.0.113.50"]
print("shop.lab.test", "in scope" if all(map(ok, shop)) else "ASK (" + ", ".join(f"{a} {'in' if ok(a) else 'out'}" for a in shop) + ")")
10.10.0.0    in scope
10.10.0.1    OUT
10.10.0.199  in scope
10.10.0.207  OUT
10.10.0.208  in scope
10.10.1.10   OUT
shop.lab.test ASK (10.10.0.30 in, 203.0.113.50 out)
Answer

10.10.0.0 (the network address, in the block: whether anything answers there is another matter), 10.10.0.199 and 10.10.0.208 are in scope; 10.10.0.1 and .207 are excluded; 10.10.1.10 is outside the /24. shop.lab.test needs a question to the client because one of its addresses belongs to a third party.

Exercise 4: passive or active, and allowed?

Classify, and say whether each is allowed on 2026-11-28 (before the window): (a) a certificate-transparency search for lab.test; (b) dig @ns.lab.test lab.test AXFR; (c) reading the client's job adverts; (d) connecting to employees on a professional network with a fake profile. Lessons: Passive and Active Reconnaissance, DNS Reconnaissance, Certificate Transparency.

Answer

(a) passive, allowed; (b) active (it reaches the client's name server), wait for the window; (c) passive, allowed; (d) social engineering with deception: not allowed unless explicitly authorised in writing, and never as part of a normal test.

Exercise 5: read a version scan

A version scan reports 21/tcp open ftp vsftpd 2.3.4 on legacy01 and 8888/tcp open http Tornado httpd 6.4 on 10.10.0.77, a host missing from the client's inventory. What do you conclude about each, and what comes next? Lessons: Service and Version Scans, From Scan Output to a Test Plan.

Answer

The FTP greeting claims vsftpd 2.3.4, a version with a known backdoored build; that is a candidate to validate safely (package and binary check with the administrator), not a confirmed finding. The Tornado service is undocumented: top priority to ask the client what it is (and whether the device is in the authorization's scope), and report the inventory gap.

Exercise 6: score it

Compute the CVSS v3.1 base score of AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N by hand from the formulas, then check it with the calculator. Lesson: CVSS v3.1.

Answer

ISS = 1 − (1 − 0.56)(1 − 0.56)(1 − 0) = 0.8064; impact = 6.42 × 0.8064 = 5.177; exploitability = 8.22 × 0.85 × 0.77 × 0.62 × 0.85 = 2.835; sum 8.012; Roundup gives 8.1, High.

Exercise 7: triage

The scanner reports CVE-2024-6387 on three Ubuntu 22.04 hosts with openssh-server packages 1:8.9p1-3ubuntu0.10, 1:8.9p1-3ubuntu0.6 and 1:8.9p1-3ubuntu0.13. The distribution's fixed version is 1:8.9p1-3ubuntu0.10. Which are false positives? Lesson: Scanner Output Triage.

Answer

0.10 and 0.13 are equal to or newer than the fix (false positives); 0.6 is older (confirmed). Compare with dpkg --compare-versions, never as strings.

Exercise 8: prioritise

Order these, with one reason each: (a) a KEV-listed flaw on the Internet-facing VPN, validated by version; (b) an unauthenticated CI console reachable by all VPN users, chaining to the database; (c) a 9.8 CVE in a library on an internal test server with EPSS in the 30th percentile; (d) weak SSH algorithms on an isolated lab VM. Lessons: EPSS and KEV, Risk Prioritisation.

Answer

(a) and (b) first (in either order; known exploitation and Internet exposure versus a demonstrated chain to critical data), then (c) (high severity but low likelihood and low exposure: normal patch cycle), then (d) (low on every axis).

Exercise 9: how far to go

You confirmed that a web application runs commands through a shell as www-data. List three post-exploitation actions you may take under a typical RoE and three you may not. Lessons: Shells and Processes, Post-Exploitation Boundaries.

Answer

May: record id, host name and OS; read the client's marker file; list (not read) the directory that shows the reach. May not (without explicit written agreement): collect password hashes; add an SSH key or any persistence; connect onward to hosts outside the scope; copy customer data.

Exercise 10: escalation, read-only

An audit of a server finds: deploy ALL=(root) NOPASSWD: /usr/bin/vim /etc/nginx/nginx.conf; a root cron job running /opt/report/run.sh with mode -rwxr-xr-x root root in a directory drwxrwxrwx root root; python3.12 with cap_net_bind_service=ep. Which are findings, and the fix for each? Lesson: Linux Privilege Escalation.

Answer

The vim rule is a finding: vim can run shell commands as root; use sudoedit with a group-owned file, or configuration management. The cron script is a finding although the script itself isn't writable: its directory is world-writable, so the file can be replaced; make the directory root-owned 0755. cap_net_bind_service only allows binding ports below 1024: not an escalation, but question why an interpreter has any capability.

Exercise 11: write for two readers

Rewrite this finding title for the executive summary, and write the engineer's verification step: "BOLA in GET /api/orders/{id} allows horizontal privilege escalation." Lessons: Executive Summary and Technical Findings, Severity, Evidence and Reproduction.

Answer

Executive: "Any customer could see every other customer's orders." Verification: "As test user lab-a, GET /api/orders/<id of an order owned by lab-b> returns 404; GET /api/orders/<id owned by lab-a> still returns 200."

Exercise 12: the retest

At the retest, the original IDOR request returns 404, but the same request against /api/v1/orders/{id} returns another user's order, and the mobile app can no longer load the user's own orders. Record the status. Lesson: Remediation Guidance and the Retest.

Answer

Partially fixed (a variant on the v1 endpoint still works) with a regression (legitimate access broken in the mobile app). Report both, with evidence and the date, and recommend fixing the ownership check in the shared data-access layer used by both API versions.

Practice problems for this course, with tests in 21 languages: CVSS v3.1 Base Score.

Test yourself

Which document answers 'how may we test'?

  1. The authorization letter
  2. The rules of engagement
  3. The NDA
  4. The invoice

What is the CVSS v3.1 base score of AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N?

  1. 7.1
  2. 8.1
  3. 8.8
  4. 9.1

A root cron script is not writable, but its directory is world-writable. Is it a finding?

  1. No
  2. Yes: the file can be replaced inside the writable directory
  3. Only on Windows
  4. Only if the script is long

At the retest the original request fails but a variant on another endpoint still works. Status?

  1. Fixed
  2. Partially fixed
  3. Risk accepted
  4. Mitigated