0Pricing
Cloud & IT Cert Prep · Lesson

Penetration Testing Phases: Recon to Reporting

Follow the pen test lifecycle: reconnaissance, scanning, exploitation, post-exploitation, and the final report that drives remediation.

Penetration Testing Phases: Recon to Reporting is a free Cloud & IT Cert Prep lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cloud & IT Cert Prep learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

The Penetration Testing Lifecycle

A structured penetration test follows a defined lifecycle that ensures thorough coverage, minimizes risk to production systems, and produces actionable results. The most widely adopted framework comes from the PTES (Penetration Testing Execution Standard) and aligns with the NIST approach. The phases are: Planning/Scoping, Reconnaissance, Scanning, Exploitation, Post-Exploitation, and Reporting. Each phase builds on the previous — you cannot exploit what you haven't discovered, and you cannot report what you haven't documented. Skipping or rushing phases leads to incomplete assessments and unreliable findings.

# Penetration testing phases:
# 1. Planning & Scoping    (Rules of Engagement)
# 2. Reconnaissance        (OSINT + passive recon)
# 3. Scanning/Enumeration  (active discovery)
# 4. Exploitation          (attacking vulnerabilities)
# 5. Post-Exploitation     (lateral movement, persistence)
# 6. Reporting             (findings + recommendations)

Phase 1: Planning and Scoping

The planning phase establishes the legal and operational foundation for the engagement. Key deliverables include: a signed Statement of Work (SOW) defining objectives and pricing; a Rules of Engagement (RoE) document specifying authorized targets, time windows, prohibited techniques, emergency contacts, and data handling requirements; and clear definition of success criteria (what constitutes achieving the objective). The scope must be precisely defined to prevent scope creep (accidentally testing unauthorized systems) and to ensure the assessment covers the most critical assets. All communication channels and escalation procedures are established before any technical work begins.

# Scoping questions to answer:
# - Which IP ranges/domains are in scope?
# - Are cloud environments (AWS/Azure/GCP) in scope?
# - Are physical attacks in scope?
# - Are employees fair game for phishing?
# - Are denial-of-service techniques permitted?
# - What notification procedures exist?
# - Who is the authorized point of contact?
# - What is the test window (dates/times)?
# - How will data be protected and destroyed after?

Phase 2: Passive Reconnaissance (OSINT)

Passive reconnaissance collects information about the target without directly interacting with their systems — using public sources that do not generate logs on the target. Sources include: WHOIS records (domain registration, registrant contact), DNS records, certificate transparency logs (revealing subdomains), LinkedIn (employee names, job titles, technologies used), job postings (reveal tech stack and tools), Shodan/Censys (internet-facing services and open ports), GitHub repositories (source code, credentials accidentally committed), and Google dorking (site-specific searches for sensitive files and exposed interfaces).

# OSINT techniques (no target contact):
# WHOIS:
whois targetcompany.com

# DNS enumeration via public resolvers:
dig @8.8.8.8 targetcompany.com ANY
dnsx -d targetcompany.com -a -aaaa -cname -mx -ns

# Certificate transparency (subdomains):
curl 'https://crt.sh/?q=%.targetcompany.com&output=json'

# Google dorks:
# site:targetcompany.com filetype:pdf confidential
# site:targetcompany.com inurl:admin
# site:github.com targetcompany password OR apikey

Phase 2: Active Reconnaissance

Active reconnaissance involves directly interacting with target systems to gather information. This generates logs on the target and is inherently noisier than passive recon. Techniques include port scanning (Nmap), service enumeration, DNS zone transfer attempts, and banner grabbing. The boundary between reconnaissance and scanning is blurry — the goal of reconnaissance is information gathering while scanning typically implies vulnerability identification. However, active recon can trigger IDS/IPS alerts and may be detected by a security-aware target, so testers balance thoroughness with stealth based on the engagement objective (test detection vs. stealth compromise).

# Active reconnaissance techniques:
# Host discovery:
nmap -sn 192.168.1.0/24 -oG alive_hosts.txt

# DNS zone transfer (if misconfigured):
dig axfr @ns1.targetcompany.com targetcompany.com

# Banner grabbing:
nc -v 192.168.1.10 22    # SSH version
curl -I https://targetcompany.com  # web server header

# SMTP enumeration:
nmap --script smtp-enum-users 192.168.1.25

# Web crawler:
whatweb targetcompany.com

Phase 3: Scanning and Vulnerability Analysis

The scanning phase systematically discovers open ports, services, software versions, and known vulnerabilities on in-scope targets. This phase uses tools like Nmap for service enumeration and Nessus/OpenVAS for vulnerability scanning. The pen tester manually reviews scanner output and correlates findings: a version of Apache identified by Nmap may match known exploits in the CVE database. This phase also includes manually probing web applications (with Burp Suite) and testing authentication mechanisms. The output is a prioritized list of potential attack paths to pursue in the exploitation phase.

# Scanning phase workflow:
# 1. Port and service scan:
nmap -sV -sC -O 192.168.1.0/24 -oX services.xml

# 2. Vulnerability scan (Nessus/OpenVAS):
# Import Nmap results -> credentialed scan -> export report

# 3. Web application scanning:
burpsuite                              # manual + scanner
niklto -h https://192.168.1.10
wpscan --url https://targetsite.com   # WordPress-specific

# 4. Correlate version with CVEs:
# searchsploit apache 2.4.41
# Check NVD: https://nvd.nist.gov/vuln/search

Phase 4: Exploitation

The exploitation phase attempts to leverage identified vulnerabilities to achieve unauthorized access, privilege escalation, or other defined objectives. Exploitation must stay strictly within scope and the Rules of Engagement. Techniques include exploiting unpatched vulnerabilities (using Metasploit or manual exploits), credential attacks (password spraying, default credentials, brute-forcing), web application attacks (SQL injection, XSS exploitation), and social engineering if authorized. Every action must be documented with timestamps: what was done, when, what the result was, and what tool was used. This documentation forms the evidence base for the final report.

# Documentation during exploitation:
# Use a testing journal (OneNote, CherryTree, Obsidian)
# For each finding, record:
# - Date/time: 2026-06-15 14:32 UTC
# - Target: 192.168.1.25 (web-prod-01)
# - Finding: SQL injection in /login.php username parameter
# - Command: sqlmap -u 'http://target/login.php' --data 'user=*&pass=x'
# - Screenshot: login_sqli_01.png
# - Impact: retrieved admin credentials from users table
# - CVSS: 9.8 (Critical)

Phase 5: Post-Exploitation

Post-exploitation begins after initial access is achieved and explores how far an attacker could extend their reach. Activities include: privilege escalation (gaining admin/root from limited user access), credential harvesting (extracting hashes, tickets, or plaintext passwords), lateral movement (accessing other systems using harvested credentials), data discovery (identifying sensitive data accessible from the compromised position), and establishing persistence (to simulate APT long-term access). The goal is to show the realistic impact of the initial compromise — not just that one system was pwned, but what the attacker could ultimately reach.

# Post-exploitation with Meterpreter (Metasploit):
meterpreter> sysinfo                  # OS/hostname
meterpreter> getuid                   # current user
meterpreter> getsystem                # attempt privilege escalation
meterpreter> hashdump                 # dump local NTLM hashes
meterpreter> run post/multi/gather/credentials
meterpreter> run post/windows/manage/migrate  # migrate to stable process

# Lateral movement (CrackMapExec with dumped hash):
crackmapexec smb 192.168.1.0/24 -u admin -H <NTLM_hash> --shares

Pivoting and Internal Network Access

Pivoting uses a compromised host as a relay to reach network segments that are otherwise inaccessible to the pen tester (e.g., an internal database VLAN only reachable from the application server). Metasploit's route add command and SSH tunneling (ssh -L for local forwarding or ssh -D for SOCKS proxy) are common pivot mechanisms. Pivoting demonstrates whether network segmentation is truly effective — a well-segmented network should prevent a compromised DMZ server from reaching internal databases, while a flat network allows free lateral movement. Documented pivot paths in the report show exactly where segmentation gaps exist.

# SSH local port forward (pivot):
# Access MySQL on internal server through compromised host:
ssh -L 3306:10.30.30.5:3306 user@compromised_host
# Now connect to MySQL locally:
mysql -h 127.0.0.1 -P 3306 -u root

# SOCKS proxy for full network pivot:
ssh -D 1080 user@compromised_host
# Use proxychains to route tools through SOCKS proxy:
proxychains nmap -sT 10.30.30.0/24

# Metasploit route add:
route add 10.30.30.0/24 <session_id>

Cleanup and Evidence Preservation

After testing is complete, pen testers must clean up — removing backdoors, accounts, and tools they installed. Unlike real attackers, pen testers are obligated by the Rules of Engagement to restore systems to their pre-test state. Cleanup items include: removing created user accounts, deleting dropped files (payloads, tools), removing persistence mechanisms (WMI subscriptions, scheduled tasks, registry run keys), and confirming with the client that all test artifacts are gone. Evidence preservation runs in parallel: retain all screenshots, tool output, logs, and notes in a secure format for report writing and potential legal reference.

# Post-test cleanup checklist:
# Windows:
# - Delete created accounts: net user testuser /delete
# - Remove scheduled tasks: schtasks /delete /tn 'TestTask'
# - Remove registry persistence: reg delete HKLM\...
# - Delete dropped files: del C:\Windows\Temp\payload.exe
# - Clear event logs (if authorized): wevtutil cl Security

# Linux:
# - Remove cron jobs: crontab -r
# - Remove added SSH keys: edit ~/.ssh/authorized_keys
# - Delete dropped files: rm /tmp/payload.sh

Phase 6: Reporting

The report is the ultimate deliverable that justifies the engagement and drives remediation. A well-structured report includes: an executive summary (risk rating, business impact, top 3 findings for leadership); a technical findings section (each finding with severity, description, evidence, reproduction steps, business impact, and specific remediation guidance); and an appendix with raw tool output and detailed timelines. Reports are classified as confidential — they contain enough detail to repeat the attack. Delivery typically involves a debrief meeting where the pen test team walks through findings and answers client questions. Good reporting is what separates professional engagements from amateur scan dumps.

Passive vs Active Reconnaissance for the Exam

Security+ frequently tests the distinction between passive and active reconnaissance. Passive recon involves gathering information from public sources without directly contacting target systems — no logs are created on the target. Examples: reading WHOIS records, reviewing LinkedIn, querying certificate transparency logs, running Shodan searches. Active recon involves directly interacting with target systems — port scanning, banner grabbing, DNS zone transfer attempts. Active recon generates logs and may trigger IDS alerts. In a real engagement, passive recon precedes active to build a map before making any detectable contact with the target network.

Quick Check

Test your understanding of CompTIA Security+ (SY0-701) concepts from this lesson.

Lesson Recap

In this lesson you learned: penetration testing follows a structured lifecycle of planning, reconnaissance, scanning, exploitation, post-exploitation, and reporting, passive reconnaissance uses public OSINT sources without creating target-side logs while active recon directly interacts with systems, and the final report with its executive summary, technical findings, and specific remediation guidance is the key deliverable that drives security improvements. Next up we explore CVSS scoring and how to prioritize vulnerability remediation.

Frequently asked questions

Is the “Penetration Testing Phases: Recon to Reporting” lesson free?

Yes — the full text of “Penetration Testing Phases: Recon to Reporting” is free to read here on the web, and the Cloud & IT Cert Prep course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cloud & IT Cert Prep course, upgrade to CoddyKit PRO.

What will I learn in “Penetration Testing Phases: Recon to Reporting”?

Follow the pen test lifecycle: reconnaissance, scanning, exploitation, post-exploitation, and the final report that drives remediation. You practise Cloud & IT Cert Prep with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Cloud & IT Cert Prep?

No prior experience is required. Cloud & IT Cert Prep on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Penetration Testing Phases: Recon to Reporting” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Cloud & IT Cert Prep lesson?

Yes. Every Cloud & IT Cert Prep lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Vulnerability Scanning vs Penetration Testing
  2. Common Scanning Tools: Nessus, OpenVAS, Nmap
  3. Penetration Testing Phases: Recon to Reporting
  4. CVSS Scoring and Vulnerability Prioritization
← Back to Cloud & IT Cert Prep