Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 3 of 6 · Lab · 30 min · revision 1

Reconnaissance and Enumeration in an Owned Lab

Execute passive and active reconnaissance, service version enumeration, and web directory brute-forcing in an isolated lab environment while capturing structured scanner output and evidence logs.

Contentsand lesson path

What you will learn

  • Run a structured assessment (reconnaissance, enumeration, vulnerability validation, controlled impact demonstration) against an intentionally vulnerable lab following NIST SP 800-115 and OWASP WSTG phases, keeping an evidence log.

Prerequisites: Web Application Security

01. Passive OSINT and Active Host Discovery

Before transmitting a single packet toward a target system, penetration testers conduct reconnaissance to map the target's external presence. Reconnaissance is divided into two distinct disciplines: passive Open Source Intelligence (OSINT) and active host discovery.

Passive Open Source Intelligence (OSINT) Passive reconnaissance gathers intelligence exclusively from public, third-party repositories without directly interacting with client infrastructure, ensuring that defensive Intrusion Detection Systems (IDS) remain completely blind to the investigator's interest:

  • Certificate Transparency Logs: Modern web PKI mandates that certificate authorities log every issued SSL/TLS certificate. Querying Certificate Transparency aggregators (such as crt.sh) exposes undocumented staging subdomains, development APIs, and internal portals (e.g., vpn-dev.corp.internal, admin-staging.example.com).
  • DNS Record Enumeration: Inspecting public DNS records (MX mail exchangers, SPF TXT records, DKIM public keys) reveals third-party email providers, cloud gateways, and federated identity tenants.
  • Internet Exposure Search Engines: Platforms like Shodan and Censys continuously crawl and index IPv4/IPv6 address spaces, allowing testers to view open ports, TLS certificate banners, and historical service versions without touching the target.
  • Code and Credential Repositories: Searching GitHub, GitLab, and public paste sites often surfaces accidentally committed API keys, database credentials, and internal network architecture diagrams.

Active Host Discovery Once passive data is cataloged, active host discovery verifies live systems within in-scope CIDR blocks. Standard ICMP echo requests (ping) are frequently blocked by perimeter firewalls. Testers deploy hybrid discovery probes combining TCP SYN packets to common ports (-PS22,80,443), TCP ACK pings (-PA80,443), and ICMP timestamp queries (-PP) to bypass stateful packet filters.

02. Port Scanning, Banner Grabbing, and Service Fingerprinting

Identifying which ports are listening and determining the exact application versions operating behind those ports transforms raw IP addresses into actionable attack surfaces.

Port Scanning Mechanics: SYN Stealth versus Connect

  • TCP SYN Stealth Scan (nmap -sS): The default scanner mode. The scanner transmits a TCP SYN packet. If the target port responds with SYN-ACK (indicating an open port), the scanner immediately responds with a RST (reset) packet rather than completing the full three-way handshake (ACK). This prevents the target application layer from creating a full socket connection, avoiding application-level audit logging on legacy servers.
  • TCP Connect Scan (nmap -sT): Completes the full three-way handshake (SYN -> SYN-ACK -> ACK), invoking standard operating system connect() syscalls. Used when raw packet creation privileges (root/admin) are unavailable.
  • UDP Port Scanning (nmap -sU): UDP is stateless; an open UDP port typically yields no response, while a closed port returns an ICMP Port Unreachable packet (Type 3, Code 3). Because operating system kernels rate-limit ICMP error generation, UDP scanning is significantly slower.

Service Version Fingerprinting and Web Directory Enumeration Relying on default port mappings is unreliable (e.g., an SSH daemon running on port 2222 or Apache listening on port 8080). Service version detection (-sV) transmits standardized probe packets and compares the returned banners against extensive fingerprint signatures. For web targets, testers deploy fast directory fuzzers (such as ffuf or gobuster) with curated wordlists (e.g., SecLists) to discover hidden administrative interfaces, backup tarballs (.tar.gz), environment variable configuration files (.env), and Swagger/OpenAPI documentation endpoints.

03. Lab: Executing Structured Service Enumeration and Parsing Scans

In this lab, you will analyze a Python scanner parser that ingests raw Nmap service discovery outputs, normalizes open port records, and identifies software components requiring vulnerability validation.

Review the script below and inspect the expected output showing discovered services and potential exploit candidates.

Python script parsing Nmap port scan telemetry and identifying attack surfaces
SCAN_TELEMETRY = [
    {
        "port": 22,
        "protocol": "tcp",
        "service": "ssh",
        "product": "OpenSSH",
        "version": "8.9p1 Ubuntu 3ubuntu0.6",
    },
    {
        "port": 80,
        "protocol": "tcp",
        "service": "http",
        "product": "Apache httpd",
        "version": "2.4.52",
    },
    {
        "port": 3306,
        "protocol": "tcp",
        "service": "mysql",
        "product": "MySQL",
        "version": "5.7.33",
    },
]

def evaluate_attack_surface(telemetry):
    print("=== DISCOVERED SERVICES & TARGET ENUMERATION ===")
    findings = []
    for item in telemetry:
        port_spec = f"{item['port']}/{item['protocol']}"
        banner = f"{item['product']} {item['version']}"
        print(f"Port: {port_spec:<9} | Service: {item['service']:<6} | {banner}")
        if "MySQL" in item["product"] and "5.7" in item["version"]:
            findings.append((port_spec, "Outdated MySQL 5.7 (EOL)"))
    return findings

candidates = evaluate_attack_surface(SCAN_TELEMETRY)
for p, note in candidates:
    print(f"  [CANDIDATE] {p} -> {note}")
Expected output: structured service discovery and vulnerability candidates
=== DISCOVERED SERVICES & TARGET ENUMERATION ===
Port: 22/tcp    | Service: ssh    | OpenSSH 8.9p1 Ubuntu 3ubuntu0.6
Port: 80/tcp    | Service: http   | Apache httpd 2.4.52
Port: 3306/tcp  | Service: mysql  | MySQL 5.7.33
  [CANDIDATE] 3306/tcp -> Outdated MySQL 5.7 (EOL)

04. Vulnerability Mapping and Service-Specific Enumeration

Following port discovery, testers transition to service-specific enumeration and vulnerability mapping.

Service-Specific Probing Protocols

  • Server Message Block (SMB / Ports 139, 445): Testers probe for null session binds and anonymous IPC$ connections using tools like enum4linux-ng or crackmapexec / netexec. Enumeration inspects password policies, domain user account lists, accessible network file shares, and checks whether SMB message signing is disabled or optional (enabling NTLM relay attacks).
  • SSH and Remote Management (Ports 22, 3389): For SSH, tools like ssh-audit evaluate supported cipher suites and key exchange algorithms, flagging legacy algorithms (such as arcfour or diffie-hellman-group1-sha1). For RDP, testers verify whether Network Level Authentication (NLA) is enforced, preventing pre-authentication denial of service or BlueKeep exploitation.
  • Database Listeners (PostgreSQL, MSSQL, Redis): Testing verifies whether database ports are inadvertently exposed to untrusted subnets. Probing tests for unauthenticated binds (common in misconfigured Redis installations), default administrative accounts (e.g., MSSQL sa or PostgreSQL postgres), and stored procedure execution rights (such as xp_cmdshell).
  • HTTP/HTTPS Services (Ports 80, 443): Testers inspect HTTP response headers for missing security flags (HSTS, Content-Security-Policy), evaluate Cross-Origin Resource Sharing (CORS) configurations, and test for HTTP method tampering (PUT, DELETE).
  • Nmap Scripting Engine (NSE): The NSE framework runs Lua scripts against discovered services. Categories include safe (non-intrusive metadata probes), discovery (active directory and account queries), and vuln (checking whether specific known CVEs exist, such as ssl-heartbleed or smb-vuln-ms17-010).

Mapping Banners to Authoritative Vulnerability Records Discovered software versions are correlated against the National Vulnerability Database (NVD) and Exploit Database. However, professional testers exercise caution with backported Linux patches (e.g., Red Hat or Ubuntu backporting security fixes into an older upstream version number without incrementing the primary version string). Blindly reporting a vulnerability based solely on an HTTP banner string without validating exploitability produces unprofessional false positive reports.

05. Practice check

Practice check · 2 questions

Practice check

Validate your understanding of passive reconnaissance, stealth port scanning mechanics, service fingerprinting, and vulnerability mapping.

Q1. What is the key technical characteristic that distinguishes passive OSINT from active port scanning?
Q2. How does a TCP SYN stealth scan (nmap -sS) identify an open port without completing a full socket connection?
Practice only: not graded, not saved, not evidence.

06. Review prompt

Explain how passive Open Source Intelligence (OSINT) enables testers to discover target assets without alerting defensive monitoring systems. Detail the specific intelligence gathered from Certificate Transparency logs, DNS records, and internet search engines like Shodan.

Contrast the technical mechanics of a TCP SYN stealth scan against a full TCP Connect scan. Explain why SYN scanning avoids full application socket creation and how UDP port scanning differs in speed and reliability.

Discuss the role of web directory fuzzing (ffuf/gobuster) in discovering unlinked attack surfaces, including administrative endpoints and exposed backup files.

Finally, analyze the process of service fingerprinting and banner grabbing. Explain why testers must account for backported security patches when cross-referencing banners against National Vulnerability Database (NVD) CVE entries.

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check