keepcalculator

06 Numbers and Powers

Stages of Penetration Tests: 7 Phases Explained

Card No. 06·86418 · Updated · Standard formula, shown below

The calculator on this card is switched off while it is checked. The formula is below, and the worked example shows how to do the sum by hand.

Penetration testing is a simulated cyberattack against a system to find exploitable vulnerabilities, and it follows a structured process of seven stages: pre-engagement, reconnaissance, scanning, vulnerability analysis, exploitation, post-exploitation, and reporting. This article walks through each phase in order, explaining what happens, what tools and techniques are used, and what the output of each stage looks like.

Formula

The calculator above works out two simple metrics that penetration testers often track:

  • Exploitation success rate = (Exploited ÷ Vulnerabilities found) × 100. This tells you what percentage of discovered vulnerabilities were actually successfully exploited during the test.
  • Time per vulnerability = Total time spent ÷ Vulnerabilities found. This shows the average number of minutes spent per vulnerability, which helps estimate how thorough the test was.

Variables are defined as:

  • t = total time spent on the test in minutes
  • v = number of vulnerabilities discovered
  • e = number of vulnerabilities successfully exploited

Worked Example

Using the default values from the calculator: total time = 60 minutes, vulnerabilities found = 5, exploited = 2.

Exploitation success rate = (2 ÷ 5) × 100 = 40.0%

Time per vulnerability = 60 ÷ 5 = 12.0 minutes

So the tester spent an average of 12 minutes per vulnerability and successfully exploited 40% of them.

Why Penetration Testing Follows Stages

Penetration testing is not a random hacking exercise. It is a formal, repeatable process. The stages exist to ensure that the test is safe, legal, thorough, and produces useful results. Without a structured approach, a tester might miss critical vulnerabilities, break systems, or fail to document findings in a way that developers can act on.

The seven stages described here align with common industry frameworks such as the PTES (Penetration Testing Execution Standard) and the OWASP Testing Guide. Different sources may merge or rename some stages, but the underlying logic is the same.

Stage 1: Pre-Engagement

This is the planning and legal phase. The tester and the client agree on the scope, goals, and rules of engagement. Key activities include:

  • Defining which systems, IP addresses, and applications are in scope.
  • Setting the testing window (e.g., after business hours).
  • Agreeing on the type of test: black-box (no prior knowledge), white-box (full knowledge), or grey-box (partial knowledge).
  • Signing a legal contract that authorizes the test and protects both parties.
  • Establishing emergency contacts and a rollback plan in case something goes wrong.

This stage is critical because unauthorized testing is illegal, even if the intent is good. The contract must clearly state what is allowed and what is not.

Stage 2: Reconnaissance

Reconnaissance is the information-gathering phase. The tester collects as much data as possible about the target before attacking it. This can be passive or active.

  • Passive recon: Using public sources like search engines, social media, WHOIS records, and DNS lookups. No direct contact with the target systems.
  • Active recon: Directly probing the target, such as sending pings, scanning ports, or querying services. This is more detectable but yields more detailed information.

Examples of information gathered: IP addresses, domain names, employee names, email formats, technology stack (web server, CMS, programming languages), and network topology. The goal is to build a map of the attack surface.

Stage 3: Scanning

In this stage, the tester uses automated tools to identify live hosts, open ports, and running services. This is where the target is probed more aggressively. Common techniques include:

  • Port scanning: Checking which TCP/UDP ports are open and which services are listening (e.g., port 80 for HTTP, port 22 for SSH).
  • Service enumeration: Determining the version of each service, which can reveal known vulnerabilities.
  • Vulnerability scanning: Using tools like Nessus or OpenVAS to compare service versions against databases of known CVEs (Common Vulnerabilities and Exposures).

This stage produces a list of potential vulnerabilities but does not yet confirm whether they are exploitable. It is also the stage where the tester must be careful not to overwhelm the target with traffic, as that could cause a denial of service.

Stage 4: Vulnerability Analysis

Once scanning is complete, the tester analyzes the results to filter out false positives and prioritize the vulnerabilities that are most likely to be exploitable and impactful. This is a manual, analytical step.

For each vulnerability, the tester considers:

  • Severity (e.g., CVSS score)
  • Ease of exploitation
  • Potential impact on confidentiality, integrity, and availability
  • Whether the vulnerability is real or a false positive from the scanner

The output is a shortlist of vulnerabilities that will be targeted in the next stage. This is also where the tester may research exploit code or proof-of-concept techniques for the specific software versions found.

Stage 5: Exploitation

This is the stage that most people think of as “hacking.” The tester attempts to actually compromise the target by using the vulnerabilities identified in the previous stage. Techniques can include:

  • SQL injection to bypass authentication or extract data.
  • Cross-site scripting (XSS) to hijack user sessions.
  • Buffer overflows to execute arbitrary code.
  • Using default credentials on exposed services.
  • Exploiting unpatched software with known exploit code.

The goal is to gain access, but the tester must do so in a controlled manner. For example, if the tester gains root access to a server, they should not read sensitive data beyond what is necessary to prove the impact. The exploitation should be documented with screenshots and timestamps.

Stage 6: Post-Exploitation

After gaining access, the tester assesses what they can do with it. This stage determines the real business impact of the vulnerability. Activities include:

  • Privilege escalation: moving from a low-privilege user to an administrator or root.
  • Lateral movement: using the compromised system to access other systems on the network.
  • Data exfiltration: demonstrating that sensitive data (e.g., customer records, credentials) can be extracted.
  • Persistence: creating a backdoor or scheduled task to maintain access.

This stage also involves cleaning up: removing any files or accounts created during the test, restoring changed settings, and ensuring the system is left as it was found. The tester must be careful not to cause lasting damage.

Stage 7: Reporting

The final stage is the deliverable: a comprehensive report that explains what was done, what was found, and how to fix it. A typical penetration test report includes:

  • An executive summary for management, written in non-technical language.
  • A detailed technical section listing each vulnerability, its severity, the steps to reproduce it, and the evidence (screenshots, logs).
  • Remediation recommendations for each vulnerability, such as patching, configuration changes, or code fixes.
  • A risk rating for each finding, often using a scale like Critical, High, Medium, Low.

The report is the main value of the test. Without it, the client has no idea what to fix or how to prioritize. A good report is clear, actionable, and free of jargon.

Common Mistakes in Penetration Testing

Even experienced testers can make mistakes. Some of the most common include:

  • Testing without a clear scope and accidentally hitting out-of-scope systems.
  • Skipping the reporting phase or writing a vague report that does not help developers.
  • Using automated tools without manual verification, leading to false positives.
  • Failing to clean up after exploitation, leaving backdoors that real attackers could use.
  • Not communicating with the client during the test, causing panic when systems go down.

These mistakes can turn a useful test into a liability. That is why following the seven stages rigorously is so important.

Penetration Testing vs. Vulnerability Scanning

People often confuse penetration testing with vulnerability scanning. A vulnerability scan is an automated tool that checks for known weaknesses and produces a list of potential issues. A penetration test is a manual, human-driven process that goes further: it actually tries to exploit the weaknesses to see if they are real and what damage they can cause.

Think of it this way: a vulnerability scan is like a doctor taking your blood pressure and checking your weight. A penetration test is like a doctor performing a stress test or a biopsy to confirm a diagnosis. Both are useful, but they answer different questions.

Frequently Asked Questions

How long does a penetration test take?

The duration depends on the size and complexity of the target. A small web application might take a few days, while a large corporate network with hundreds of systems can take weeks. The pre-engagement and reporting phases add time on top of the actual testing. Most tests are measured in weeks, not hours.

Is penetration testing legal?

Yes, but only if you have written authorization from the system owner. The pre-engagement contract is what makes it legal. Unauthorized testing is a crime in most jurisdictions, even if you are trying to help. Always get explicit, written permission before testing any system you do not own.

What is the difference between red team and penetration testing?

A penetration test is focused on finding and exploiting vulnerabilities in a specific scope. A red team exercise is broader: it simulates a full adversarial attack, including social engineering, physical intrusion, and evasion of detection, with the goal of testing the organization’s overall security posture. Red teaming is more complex and expensive.

Can penetration testing break systems?

Yes, there is always a risk. Exploiting a vulnerability can crash a service or cause data corruption. That is why the pre-engagement phase includes rollback plans and emergency contacts. Testers are supposed to be careful and stop if something unexpected happens, but the risk can never be zero.

What skills do I need to become a penetration tester?

You need a solid foundation in networking, operating systems (especially Linux and Windows), and programming (Python, Bash, or similar). Knowledge of web application security (OWASP Top 10) and common tools like Nmap, Burp Suite, and Metasploit is essential. Certifications like OSCP or CEH are helpful but not mandatory.

How often should a company do penetration testing?

There is no universal rule, but many organizations do it annually, after major changes (like a new application or infrastructure upgrade), or when they need to meet compliance requirements such as PCI-DSS. Some high-security environments do it more frequently, such as quarterly or after every significant release.

Related

Formula used
in t | Total time (min) | min | 60 | 0
in v | Vulnerabilities found | count | 5 | 0
in e | Exploited | count | 2 | 0
out rate | Exploitation success rate | % | (e / v) * 100 | 1
out per_vuln | Time per vulnerability | min | t / v | 1

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →