Skip to main content
Port Scanning & Deep Service Enumeration (HTTP, SMB, SSH, SNMP)
Lesson 3 of 11

Port Scanning & Deep Service Enumeration (HTTP, SMB, SSH, SNMP)

Scan TCP and UDP ports accurately with Nmap, then enumerate HTTP, SMB, SSH, and SNMP services to map reachable attack surfaces and harden exposed configurations.

Intermediate 30 min Pentesting
Authorised environments only — The techniques described here are used only in training labs and on systems you own or have written permission to test.

Learning objectives

  • Explain how Nmap TCP SYN, TCP connect, and UDP scans detect open, closed, and filtered ports
  • Enumerate hidden web directories and virtual hosts safely using Gobuster
  • Inspect SMB shares, SSH algorithms, and SNMP MIB data using smbclient, enum4linux, and snmpwalk
  • Apply defensive hardening to reduce unnecessary port exposure and anonymous service leakage

Recommended first: Pentesting Methodology, Rules of Engagement and EthicsPassive & Active Information Gathering

#Why this matters

Finding a live IP during reconnaissance only proves a host is online. Port scanning shows which doors exist, and service enumeration reveals what runs behind them: an outdated web server, a readable file share, or a management protocol leaking internal routes.

A port number alone never guarantees what is listening there. Administrators move SSH to port 2222, run administrative APIs on port 8080, or leave SNMP open on UDP 161. Careful enumeration prevents both testers and defenders from missing real exposure.

#Port scanning fundamentals with Nmap

Nmap classifies ports into three primary states based on target replies:

  • open: An application is accepting connections on that port.
  • closed: The host is reachable, and the OS replies (RST or ICMP unreachable) showing nothing is listening.
  • filtered: A firewall dropped the probe or blocked the reply, so Nmap cannot determine the port state.

With raw-socket privileges, -sS (SYN scan) sends a SYN packet; on receiving SYN-ACK, Nmap marks the port open and sends RST instead of ACK, avoiding a full connection. Without root privileges, -sT completes the full three-way handshake via the OS connect() call.

TCP SYN scan (-sS) half-open probeTCP SYN scan (-sS) half-open probeScannerTargetSYN (port 80)SYN-ACKRST (aborts before full handshake)Fast and avoids application connection logs

By default, Nmap scans only the 1,000 most common TCP ports. A reliable two-stage workflow scans all 65,535 TCP ports (-p-), then runs version detection (-sV) and default safe scripts (-sC) only on open ports. Also check UDP (-sU): because UDP lacks a handshake, scans are slower and rely on ICMP port-unreachable replies for closed ports.

Two-stage Nmap scan on an authorised lab host
$ nmap -sS -p- --min-rate 1000 10.10.10.15
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
445/tcp  open  microsoft-ds
$ nmap -sV -sC -p 22,80,445 10.10.10.15
PORT    STATE SERVICE     VERSION
22/tcp  open  ssh         OpenSSH 8.9p1 Ubuntu 3
80/tcp  open  http        nginx 1.18.0 (Ubuntu)
445/tcp open  netbios-ssn Samba smbd 4.15.13-Ubuntu

#Web and directory enumeration (HTTP/HTTPS)

On HTTP ports (80, 443, 8080), inspect response headers (curl -I), /robots.txt, and HTML source before running wordlists. Next, use gobuster in dir mode for hidden paths or vhost mode for virtual hosts sharing one IP. Test a random nonexistent path first: if the server returns 200 OK for missing URLs, filter that response size with --exclude-length to avoid false positives.

Enumerating directories on a lab web server
$ gobuster dir -u http://lab.local -w /usr/share/wordlists/dirb/common.txt -x php,txt -t 20
/admin                (Status: 301) [Size: 169] [--> http://lab.local/admin/]
/backup.txt           (Status: 200) [Size: 412]
/robots.txt           (Status: 200) [Size: 64]

#Infrastructure services: SMB, SSH, and SNMP

Service Default port Primary tools What enumeration reveals
SMB 445/tcp smbclient, enum4linux Shares, guest/null access, OS info, users
SSH 22/tcp ssh, Nmap NSE Version banner, auth methods, weak ciphers
SNMP 161/udp snmpwalk, Nmap NSE Processes, open ports, routing tables

SMB (445/tcp): Test whether anonymous listing is enabled before trying credentials. smbclient -L lists shares and enum4linux -a automates share, policy, and user checks.

Listing SMB shares with an anonymous session
$ smbclient -L //10.10.10.15 -N
	Sharename       Type      Comment
	---------       ----      -------
	IPC$            IPC       IPC Service (lab-fileserver)
	public          Disk      Read-only team files
	backups         Disk      Nightly configs
$ smbclient //10.10.10.15/public -N -c "ls"
  .                                   D        0  Mon Nov 16 09:10:00 2026
  onboarding-notes.txt                N      842  Mon Nov 16 09:12:00 2026

SSH (22/tcp): Enumerating SSH focuses on configuration rather than password guessing. Check the banner, verify allowed authentication methods (ssh -v), and inspect supported algorithms with nmap --script ssh2-enum-algos -p 22 10.10.10.15.

SNMP (161/udp): SNMP runs over UDP and is easy to miss if you skip -sU. Legacy SNMPv1/v2c use plaintext community strings like public. With a valid string, snmpwalk -v2c -c public 10.10.10.15 dumps running processes, listening sockets, and routes from the Management Information Base (MIB).

#Defending and common mistakes

Defenders harden services to minimise what enumeration exposes:

  • Minimise exposed ports: Bind admin interfaces to localhost or a management VLAN and enforce host firewalls.
  • Harden SMB: Disable SMBv1, block null/guest sessions, enable SMB signing, and restrict share permissions.
  • Upgrade SNMP: Replace SNMPv1/v2c with SNMPv3 (authPriv authentication and encryption) and source IP ACLs.
  • Secure SSH and HTTP: Enforce key authentication (PasswordAuthentication no), remove weak ciphers, and keep backup files out of web roots.

Common enumeration mistakes:

  • Scanning only top 1,000 TCP ports: Missing high TCP ports or skipping UDP leaves major services unseen.
  • Ignoring soft 404s in Gobuster: Skipping a baseline check turns gobuster output into thousands of false hits.
  • Running noisy scripts blindly: Aggressive NSE scripts or excessive threads can crash fragile services or lock accounts.

#Summary

  • Nmap classifies ports as open, closed, or filtered; scanning all TCP ports (-p-) before -sV -sC gives complete coverage, while -sU catches UDP services.
  • Web enumeration pairs manual header and robots.txt checks with filtered gobuster dir or vhost scans.
  • smbclient, enum4linux, SSH algorithm scripts, and snmpwalk expose misconfigured shares, weak crypto, and leaked system state.
  • Defenders reduce risk by firewalling management ports, disabling guest SMB and SNMPv1/v2c, requiring SSH keys, and cleaning web directories.

Knowledge check

Sign in to take the test, complete lessons and save your progress. Log in

Practice: test your knowledge