Reconnaissance · Part 03

Service Enumeration & Banner Grabbing with Nmap

Learn open port scanning, TCP and UDP enumeration, banner grabbing with Netcat, curl and OpenSSL, service version detection and Nmap NSE scripts. Includes installation steps, commands and example outputs.

Nmap Banner Grabbing Service Enumeration TCP / UDP VAPT
Getting Started

What Is Service Enumeration?

Service enumeration is the process of identifying running network services, open ports, software versions and configuration information.

For example, a server may have SSH on port 22, HTTP on port 80 and HTTPS on port 443.

Illustrative Service List
22/tcp    open    ssh
80/tcp    open    http
443/tcp   open    https
3306/tcp  open    mysql
Authorized testing only: Scan systems you own or have permission to assess. Use conservative scan settings on production networks.
Visual Explanation

How Service Enumeration and Banner Grabbing Work

Service enumeration and banner grabbing workflow Nmap finds open ports on an authorized server. Banner grabbing tools request service information, and the server returns example SSH and HTTP details. Tester Nmap · Netcat Requests Server 192.0.2.10 Ports 22, 80, 443 SSH Banner OpenSSH HTTP Headers Server: nginx TLS Details Certificate Find Ports → Collect Banners → Identify Services
Different services expose different types of information.
Fundamentals

Important Ports for Service Enumeration

PortServicePurpose
21FTPFile transfer
22SSHRemote administration
25SMTPEmail delivery
53DNSDomain name resolution
80HTTPWeb traffic
110POP3Email retrieval
139/445SMBFile and printer sharing
143IMAPEmail access
443HTTPSEncrypted web traffic
3306MySQLDatabase service
3389RDPRemote desktop
5432PostgreSQLDatabase service
8080HTTP AlternateWeb applications
These are common defaults. A service can run on a different port.
Tool Setup

Install Nmap on Kali Linux

Nmap is a network scanner used for host discovery, port scanning and service identification.

Step 1 — Installation

Bash · Install Nmap
sudo apt update
sudo apt install nmap

Step 2 — Verify Installation

Bash · Version
nmap --version
Example Output Format
Nmap version X.YZ
Platform: x86_64-pc-linux-gnu
Scanning · Part 01

Basic Nmap Port Scanning

A port scan checks which network ports are open, closed or filtered.

Basic Scan

Bash · Basic Scan
nmap 192.0.2.10

Scan Specific Ports

Bash · Specific Ports
nmap -p 22,80,443 192.0.2.10

Scan All TCP Ports

Bash · All TCP Ports
nmap -p- 192.0.2.10
Illustrative Output
PORT     STATE  SERVICE
22/tcp   open   ssh
80/tcp   open   http
443/tcp  open   https
FlagPurpose
-pChoose specific ports
-p-Scan all ports for the selected protocol
-FFast scan of fewer common ports
--top-ports 100Scan 100 common ports
Scanning · Part 02

TCP SYN and TCP Connect Scanning

TCP SYN Scan

Sends a SYN packet to examine the port response without normally completing the TCP handshake.

Bash · SYN Scan
sudo nmap -sS -p 22,80,443 192.0.2.10

TCP Connect Scan

Uses the operating system to establish TCP connections.

Bash · Connect Scan
nmap -sT -p 22,80,443 192.0.2.10
SYN scanning generally requires elevated privileges. Both scanning methods can be logged by the target.
Scanning · Part 03

UDP Port Scanning

UDP scanning can identify services such as DNS, NTP and SNMP.

Bash · UDP Scan
sudo nmap -sU -p 53,123,161 192.0.2.10
Illustrative Output
PORT     STATE         SERVICE
53/udp   open          domain
123/udp  open|filtered ntp
161/udp  closed        snmp

open|filtered means Nmap cannot reliably tell whether the port is open or filtered.

Banner Grabbing · Tool 01

Banner Grabbing with Netcat

What is Netcat? A networking utility used to establish TCP or UDP connections and exchange data.

Step 1 — Install Netcat

Bash · Installation
sudo apt update
sudo apt install netcat-openbsd

Step 2 — Grab an SSH Banner

Bash · SSH Banner
nc -nv -w 5 192.0.2.10 22
Illustrative Output
Connection to 192.0.2.10 22 port [tcp/*] succeeded!
SSH-2.0-OpenSSH_9.6

Step 3 — Read an FTP Banner

Bash · FTP Banner
nc -nv -w 5 192.0.2.10 21
Illustrative Output
220 FTP server ready
OptionPurpose
ncRun Netcat
-nDisable DNS lookups
-vVerbose output
-w 5Set a timeout of 5 seconds
22SSH port
21FTP port
Banner Grabbing · Tool 02

HTTP Banner Grabbing with curl

HTTP servers may reveal information in response headers, including the server software or framework.

Step 1 — Install curl

Bash · Installation
sudo apt update
sudo apt install curl

Step 2 — Inspect HTTP Headers

Bash · HTTP Headers
curl -I https://example.com
Illustrative Output
HTTP/2 200
server: nginx
content-type: text/html
cache-control: max-age=3600

The server header may identify the web server, but many sites remove or modify this information.

Show Detailed Connection Information

Bash · Verbose Headers
curl -v -I https://example.com
FlagPurpose
-IRequest response headers using HEAD
-vShow verbose connection details
Banner Grabbing · Tool 03

TLS Information Gathering with OpenSSL

OpenSSL can establish TLS connections and display information about certificates and negotiated encryption settings.

Step 1 — Install OpenSSL

Bash · Installation
sudo apt update
sudo apt install openssl

Step 2 — Inspect a TLS Connection

Bash · TLS Inspection
openssl s_client -connect example.com:443 -servername example.com
Illustrative Output
CONNECTED
Certificate chain
 0 s:CN = example.com
   i:CN = Example Certificate Authority

Protocol: TLSv1.3
Cipher: TLS_AES_256_GCM_SHA384

Simplified example. Real OpenSSL output contains additional certificate and handshake details.

OptionPurpose
s_clientStart a TLS client connection
-connectHost and port
-servernameSend the TLS SNI hostname
Service Detection

Nmap Service Version Detection

Nmap uses service probes and response patterns to identify software and possible versions.

Detect Service Versions

Bash · Version Detection
nmap -sV -p 21,22,80,443 192.0.2.10
Illustrative Output
PORT    STATE SERVICE  VERSION
21/tcp  open  ftp      FTP server
22/tcp  open  ssh      OpenSSH 9.x
80/tcp  open  http     Apache httpd 2.4.x
443/tcp open  ssl/http nginx

Operating System Detection

Bash · OS Detection
sudo nmap -O 192.0.2.10
FlagPurpose
-sVDetect service versions
-OOperating system detection
-PnSkip host discovery
Nmap Scripting Engine

NSE Scripts for Service Enumeration

NSE scripts help collect more information from identified network services.

Run Default Scripts

Bash · Default NSE
nmap -sC -p 22,80,443 192.0.2.10

Combine Scripts and Version Detection

Bash · Service Enumeration
nmap -sC -sV -p 22,80,443 192.0.2.10

Run HTTP Title Script

Bash · HTTP Title
nmap -p 80 --script http-title 192.0.2.10
Illustrative Output
80/tcp open http
|_http-title: Example Website
Protocol Enumeration

HTTP and HTTPS Service Enumeration

Web service enumeration helps identify page titles, HTTP headers and server information.

Nmap HTTP Headers

Bash · HTTP Headers
nmap -p 80,443 --script http-headers 192.0.2.10

Identify Web Technologies

Bash · WhatWeb
whatweb https://example.com
Protocol Enumeration

SSH Service Enumeration

SSH enumeration can identify server versions and supported cryptographic algorithms.

Bash · SSH Version
nmap -sV -p 22 192.0.2.10
Bash · SSH Algorithms
nmap -p 22 --script ssh2-enum-algos 192.0.2.10
Illustrative Output
22/tcp open ssh
| ssh2-enum-algos:
|   kex_algorithms:
|     curve25519-sha256
|   server_host_key_algorithms:
|     ssh-ed25519
Protocol Enumeration

FTP Service Enumeration

FTP enumeration identifies server information and checks whether anonymous access is enabled.

Bash · FTP Version
nmap -sV -p 21 192.0.2.10
Bash · Anonymous FTP
nmap -p 21 --script ftp-anon 192.0.2.10
Illustrative Output
21/tcp open ftp
| ftp-anon:
|_  Anonymous FTP login allowed
Anonymous FTP access is not always a vulnerability. It depends on intended access and file permissions.
Protocol Enumeration

SMB Service Enumeration

SMB commonly runs on TCP port 445 and supports network file sharing.

Identify SMB Protocol Versions

Bash · SMB Protocols
nmap -p 445 --script smb-protocols 192.0.2.10

Enumerate SMB Shares

Bash · SMB Shares
nmap -p 445 --script smb-enum-shares 192.0.2.10
Illustrative Output
445/tcp open microsoft-ds
| smb-protocols:
|   dialects:
|     2.1
|     3.0
|_    3.1.1
Protocol Enumeration

DNS Service Enumeration

DNS commonly uses port 53 over UDP and TCP. It resolves domain names into IP addresses.

Detect DNS Service

Bash · DNS Version
sudo nmap -sU -sV -p 53 192.0.2.10

Query DNS Records

Bash · dig
dig example.com A +short
dig example.com MX +short
dig example.com NS +short
Practical Example

Complete Service Enumeration Workflow

Replace the documentation IP address with your authorized lab target.

Step 1 — Discover Open Ports

Nmap · Port Scan
nmap --top-ports 100 192.0.2.10

Step 2 — Grab Service Banners

Netcat · SSH Banner
nc -nv -w 5 192.0.2.10 22
curl · HTTP Headers
curl -I https://example.com

Step 3 — Identify Service Versions

Nmap · Version Detection
nmap -sV -p 22,80,443 192.0.2.10

Step 4 — Run Default NSE Scripts

Nmap · Scripts
nmap -sC -sV -p 22,80,443 192.0.2.10

Step 5 — Save Findings

Nmap · Save Output
nmap -sC -sV -p 22,80,443 -oN enumeration.txt 192.0.2.10
Output FlagPurpose
-oNSave normal text output
-oXSave XML output
-oGSave grepable output
-oASave several output formats
Quick Revision

Service Enumeration and Banner Grabbing Cheat Sheet

Tool / FlagPurpose
Nmap -pSpecific ports
Nmap -p-All ports for the selected protocol
Nmap -sSTCP SYN scan
Nmap -sTTCP Connect scan
Nmap -sUUDP scan
Nmap -sVService version detection
Nmap -sCDefault NSE scripts
Nmap -OOS detection
nc -nvConnect and read plaintext banners
curl -IHTTP response headers
openssl s_clientTLS connection information
Nmap -oNSave scan output

Key takeaway: Port scanning identifies possible services. Banner grabbing collects service information. Version detection and NSE scripts help investigate services in more detail.

Next Lesson: Vulnerability Assessment

Learn how to review discovered services, identify possible security weaknesses and verify findings using appropriate security testing techniques.

Explore More Tutorials →