Skip to content
Tutorials Center
My learning

Topics

Lesson 23 of 31 ยท Exploitation Concepts and Reporting

The Penetration Test Lifecycle

Follow a penetration test from scoping to retest: reconnaissance, assessment, validation, cleanup, reporting, and how PTES and NIST SP 800-115 describe the phases, with a Python tracker.

A penetration test is not a random hacking session. It is a project: it has a customer, a written agreement, a start and end date, a method, evidence and a deliverable. The method is what separates a professional test from an unstructured one. It makes the work repeatable, keeps it inside the law, and ensures the customer gets what they paid for: a clear picture of risk and a way to reduce it.

This lesson walks through the lifecycle from the first conversation to the retest. It ties together everything in the course so far: the authorization rules from Law, Ethics and Authorization, the reconnaissance and scanning concepts, the Vulnerability Assessment Workflow and the exploitation ideas from Exploitation, Privilege Escalation and Post-Exploitation Concepts. The runnable part is a small tracker that follows phases and findings in an invented engagement.

A test has a shape

Plan Scope, rules and dates are agreed in writing.
Assess Gather information and find weaknesses.
Validate Prove which findings are real.
Report Explain risk and how to fix it.

Then clean up and retest.

1 / 2

Phase 0: scoping and the paperwork

Nothing technical happens until these are settled and signed:

  • Goals: why is the test happening? A compliance requirement, a new product launch, a check after an incident? A test of a web application differs from a test of an office network.
  • Scope: exactly which addresses, domains, applications and buildings are in. Just as important, which are out: third-party services, cloud providers' shared infrastructure and production systems that cannot tolerate scanning.
  • Rules of engagement: allowed techniques, forbidden techniques (for example no denial of service, no social engineering of executives), testing windows, and the emergency contact who can stop the test.
  • Authorization: a signed document from someone with the authority to grant it. If the systems belong to a hosting provider or a cloud, their policies apply too.
  • Data handling: how findings and any captured data will be stored, encrypted and destroyed.
  • Test type: black box (tester knows nothing), white box (full documentation and often source code) or grey box (some knowledge, such as a normal user account). White and grey box finds more in less time; black box is closer to an outsider's view.

Many problems later trace back to a vague scope. Write it down in terms a stranger could follow: a list of addresses beats "the web servers".

The frameworks: PTES and NIST

Two widely used descriptions give names to the work.

PTES (Penetration Testing Execution Standard) has seven phases:

  1. Pre-engagement interactions (scoping, contracts)
  2. Intelligence gathering
  3. Threat modeling
  4. Vulnerability analysis
  5. Exploitation
  6. Post-exploitation
  7. Reporting

NIST SP 800-115 (the US technical guide to security testing) describes four phases: planning, discovery (scanning and vulnerability analysis), attack (verify vulnerabilities, with a feedback loop back into discovery) and reporting. Its feedback loop is a useful picture: attacking something often reveals new things to discover.

flowchart LR
    P["Planning and scoping"] --> D["Discovery:<br/>recon and scanning"]
    D --> A["Attack:<br/>validate findings"]
    A -->|"new access, new targets"| D
    A --> R["Reporting"]
    R --> C["Cleanup and retest"]

Discovery and validation loop until the agreed time or scope runs out.

Other standards exist for specific areas, such as the OWASP Web Security Testing Guide for web applications and OSSTMM. Choose one, follow it, and cite it in the report, so the customer knows the method.

Reconnaissance and assessment

With scope in hand, the technical work begins, using the concepts from the earlier chapters:

Keep notes and evidence from the first minute: commands run, times, addresses, outputs and screenshots. Without them you cannot reproduce a finding, and the customer cannot verify it. A timestamped log of activity also protects you: if something breaks during the test window, the log shows what you were or were not doing.

Validation and the limits of exploitation

A scanner says a service "might be vulnerable". Validation is the step that turns a maybe into evidence. Depending on the rules of engagement, that may be a harmless proof (reading a banner that proves the version, showing that a login page accepts a default password) rather than a full compromise.

Professional habits at this stage:

  • Prefer the least invasive proof that is convincing.
  • Stop when you have the evidence. Do not browse customer data for fun; capture the minimum needed (a file name, a screenshot with sensitive values hidden).
  • Avoid anything that could crash a production system unless specifically agreed.
  • Stop and call the emergency contact if you find evidence of a real attacker already present or of an unexpected, serious exposure (for example, a database full of personal data open to the internet). That is an incident, not a bullet point for the final report.
  • Do not step outside scope even if a system looks inviting. If an in-scope server connects to an out-of-scope one, ask before going further.

How deep to go is a business decision. Some customers want a "stop at proof" test; others want to know how far an intruder could get, with a pivot from one system to another. Both are legitimate when agreed in writing.

Cleanup

Testing changes things. Cleanup removes what you added so the customer is not left less secure than before:

  • Remove files, accounts, scheduled tasks and services created during testing.
  • Restore any settings you changed (and list anything you could not restore).
  • Revoke shared credentials or keys you used.
  • Securely store or destroy collected data according to the agreement.
  • Confirm in writing what was cleaned and what remains.

A clean-up list kept during the test makes this quick. It is far easier to record "created test account X on host Y" at the moment you do it than to remember a week later.

Reporting and the debrief

The report is the product (Writing a Professional Security Report). Most customers never see your tools; they see this document. A good engagement ends with the report delivered through a secure channel, followed by a debrief meeting where the testers explain the findings, answer questions and agree on priorities. Do not email vulnerabilities in plain text to a long list of recipients.

Remediation and retest

Finding problems is only useful if they get fixed. After the customer has remediated, the retest repeats the specific checks for each finding and records whether it is now resolved, partly resolved or still present. A retest is usually shorter, cheaper and often included in the contract. Findings that cannot be fixed immediately are recorded as accepted risk with an owner, a reason and a review date, never silently dropped.

Over several engagements the trend matters: fewer high-severity findings, faster fixes, and the same classes of issue not returning. That is the customer's real return on a test.

A stand-in: track phases and findings

Real teams use ticketing tools or reporting platforms. This stand-in models the idea in plain Python: an engagement with phases that must go in order, and findings that carry a status. The data is invented.

Python Track engagement phases and findings

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.

The order check is deliberately strict to make a point: skipping a phase, such as reporting findings that were never validated, is a typical way tests go wrong.

A stand-in: retest results

After fixes, the retest compares the old findings with new evidence. This version records the outcome of each retest check and summarizes remediation.

Python Summarize retest outcomes

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.

Of the two high-severity findings, one is resolved and one is still open, which the last line makes visible. A report that says "40% fixed" hides this; showing counts by severity tells the customer what to do next.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What must be settled in writing before any technical testing begins?

    Without a signed scope and authorization, testing may be illegal and the customer's expectations are undefined.
  2. 2. In a grey-box test, the tester has:

    Grey box sits between black box (nothing) and white box (everything). A normal user account is a typical example of partial knowledge.
  3. 3. Why does NIST SP 800-115 describe a loop between the attack and discovery phases?

    Gaining a foothold often shows new networks or hosts, which feed another round of discovery, within the agreed scope.
  4. 4. A tester finds a database full of personal data open to the internet. What is the best action?

    A serious live exposure is urgent. Notify the agreed contact, collect the minimum evidence and never copy or share the data.
  5. 5. What is the purpose of a retest?

    A retest verifies the fixes. Findings that remain are tracked, and accepted risks are recorded with an owner and review date.

Summary

  • A penetration test is a project: scope, rules of engagement, authorization and data handling are written and signed first.
  • PTES lists seven phases and NIST SP 800-115 lists four; both cover planning, discovery, attack or validation, and reporting.
  • Discovery and validation loop within scope; keep timestamped notes and evidence from the start.
  • Validate with the least invasive proof that convinces, stop for serious live exposures, and never leave scope.
  • Cleanup removes test artifacts; the report and debrief explain risk; the retest verifies the fixes.
  • Track accepted risks with an owner and a date rather than dropping them.
  • The Python examples are stand-ins for tracking tools and use invented data.

Next: Writing a Professional Security Report.