ERROR DEXby Akshay kumar
STUDY MODE / OFFENSIVE / NMAP
OFFENSIVE · RECONNAISSANCE

Nmap

Nmap ("Network Mapper") is the standard tool for discovering what is alive on a network, which ports are open, what services are listening and often which operating system is running. Every penetration test starts here.

Version beats port number. "Tomcat 9.0.30" is a lead you can chase; "8080 open" is noise.
UDP is where forgotten services hide — SNMP, DNS, NTP still ship with weak defaults.
Every scan is evidence. -oA or you will re-scan the same range tomorrow.
HOW TO USE IT →WHY IT MATTERSCOMMANDSMISTAKES
LICENCEOpen source
PLATFORMLinux · Windows · macOS
WRITTEN INC++ / C / Python / Lua
FIRST RELEASE1997

What it is

Nmap is a port scanner — but calling it just a port scanner undersells it. It is a network discovery and security auditing tool that answers four questions in sequence: which hosts are up, which ports are open, what service is behind each port, and what version of that service is running.

It was written by Gordon Lyon (known as Fyodor) and released in 1997. It is free and open source, and it ships by default in Kali Linux, Parrot OS and most security distributions. Nmap is not a hacking tool in itself — it produces information. What you do with that information is the offensive part, and that is where authorisation matters.

The feature that makes Nmap more than a scanner is the NSE — Nmap Scripting Engine. Scripts written in Lua can brute-force logins, check for known CVEs, enumerate SMB shares, query DNS records and much more. That turns Nmap from "what is open" into "what is open and what is wrong with it".

WALKTHROUGH

How to use Nmap

Follow it exactly as you would in a real session — every command, every line of output, and what each result actually tells you. This is a terminal walkthrough.

01

Confirm the target is alive before scanning

KALI LINUX
kali@errordex:~$ ping -c 2 scanme.nmap.org
PING scanme.nmap.org (45.33.32.156) 56(84) bytes of data.
64 bytes from 45.33.32.156: icmp_seq=1 ttl=53 time=28.4 ms
64 bytes from 45.33.32.156: icmp_seq=2 ttl=53 time=28.1 ms

--- scanme.nmap.org ping statistics ---
2 packets transmitted, 2 received, 0% packet loss
WHAT THIS MEANSTwo replies means the host is up and reachable. The ttl=53 hints the host is several hops away — TTL starts near 64 on Linux, so roughly 11 routers in between. If this had timed out, everything after it would be wasted time.
02

Fast scan: top 1000 ports with version detection

KALI LINUX
kali@errordex:~$ nmap -sV -T4 scanme.nmap.org
Starting Nmap 7.94SVN ( https://nmap.org )
Nmap scan report for scanme.nmap.org (45.33.32.156)
Host is up (0.031s latency).
# 996 ports answered RST — closed, and skipped from the output
Not shown: 996 closed tcp ports (reset)

PORT      STATE SERVICE    VERSION
22/tcp    open  ssh        OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13
80/tcp    open  http       Apache httpd 2.4.7 ((Ubuntu))
9929/tcp  open  nping-echo Nping echo
31337/tcp open  tcpwrapped

Nmap done: 1 IP address (1 host up) scanned in 12.84 seconds
WHAT THIS MEANSRead the VERSION column, not the port numbers. "OpenSSH 6.6.1p1" and "Apache 2.4.7" are searchable facts — you can look up known issues for those exact versions. tcpwrapped on 31337 means the connection was accepted then closed by TCP wrappers: something is filtering access.
03

Full port sweep — find what the fast scan missed

KALI LINUX
kali@errordex:~$ sudo nmap -sS -p- -T4 --min-rate 1000 scanme.nmap.org
PORT      STATE SERVICE
22/tcp    open  ssh
80/tcp    open  http
9929/tcp  open  nping-echo
31337/tcp open  tcpwrapped

Nmap done: 1 IP address (1 host up) scanned in 61.27 seconds

# Same four ports here — but on other hosts this is where you
# find 8080, 8443, 9000, 3306, 5432, 6379, 27017 …
WHAT THIS MEANSSame result as the fast scan, which is useful information: nothing is hiding on high ports here. On real targets this step routinely finds admin panels and databases listening on 8000-9999 that the top-1000 list never touches.
04

Targeted scripts — turn ports into findings

KALI LINUX
kali@errordex:~$ nmap -sV --script http-headers,http-title -p 80 scanme.nmap.org
PORT   STATE SERVICE VERSION
80/tcp open  http    Apache httpd 2.4.7 ((Ubuntu))
|_http-title: Go ahead and ScanMe!
| http-headers:
|   Date: Sat, 14 Nov 2026 04:12:08 GMT
|   Server: Apache/2.4.7 (Ubuntu)
|   X-Frame-Options: (missing)
|_  (Connection: close)

# Missing security headers = a low-severity but real finding
WHAT THIS MEANSThe script output is where a scan becomes a report. Server: Apache/2.4.7 confirms the version independently. X-Frame-Options missing is a clickjacking exposure you can cite directly.
05

Save everything — this is your evidence

KALI LINUX
kali@errordex:~$ nmap -sV -oA scans/scanme_2026-11-14 scanme.nmap.org
Nmap done: 1 IP address (1 host up) scanned in 12.84 seconds

$ ls scans/
scanme_2026-11-14.nmap    # human readable
scanme_2026-11-14.xml     # import into Metasploit / tools
scanme_2026-11-14.gnmap   # grep-able one-liners
WHAT THIS MEANS-oA writes all three formats at once. The XML is what you feed into other tools; the .nmap file is what you paste into a report. Without this, re-scanning later costs you the same time again.

Flags & options

FLAGWHAT IT DOES
-snPing sweep only — find live hosts, no port scan.
-sSSYN scan: half-open, fast, needs root. The default choice.
-sTConnect scan: full handshake, works without root, noisier.
-sUUDP scan. Slow, but the only way to see DNS, SNMP, NTP.
-sVProbe open ports to identify product and version.
-OGuess the operating system from TCP/IP behaviour.
-p-Scan all 65535 ports instead of the top 1000.
-p 22,80,443Scan only the ports you name.
-T0 … -T5Timing template. -T4 is fast; -T5 is reckless and causes false results.
--min-rate 1000Force at least 1000 packets per second. Speeds up big sweeps.
--script vulnRun the NSE vulnerability category against found services.
-oA nameSave output in normal, XML and grepable formats.
-v / -vvVerbose — show progress and results as they arrive.
--reasonShow why Nmap thinks a port is in that state.

Why it matters

Every engagement, every CTF box, every internal assessment starts with the same question: what is reachable? Nmap answers it in seconds. The analysts who get good at Nmap are the ones who read the version strings, not the port numbers — "port 8080 open" is noise, "Apache Tomcat 9.0.30" is a lead you can search for a CVE.

How it works

Nmap works by sending carefully crafted packets and analysing what comes back — or what does not come back. The response pattern tells you the state of a port:

The scan type decides which packets are sent. A SYN scan (-sS) sends a TCP SYN, reads the reply and then tears the connection down before it completes — fast and quiet, and it needs root. A connect scan (-sT) completes the full TCP handshake using the operating system, so it works without root but is slower and leaves full connections in logs. A UDP scan (-sU) is slow by nature because UDP gives no acknowledgement.

Service detection (-sV) goes further: after finding an open port, Nmap probes the service and compares the replies against a database of thousands of signatures to identify the product and version — for example "OpenSSH 8.9p1" rather than just "port 22 open". OS detection (-O) analyses subtle differences in how the target's TCP/IP stack behaves.

WHAT IT DOES

Sends a TCP SYN. If the port replies SYN-ACK it is open; RST means closed; nothing means filtered. The handshake is never completed, so the connection never appears in the application log.

WHEN TO USE

Default choice on any network where you can use root. Fast, quiet, and the most accurate TCP scan.

TRADE-OFF

Needs raw socket privileges. Some stateful firewalls and IDS engines specifically alert on half-open connections.

WHAT IT DOES

Uses the operating system's own connect() call — a full TCP handshake for every port.

WHEN TO USE

When you have no root, or when scanning through a proxy or SOCKS tunnel where raw packets are impossible.

TRADE-OFF

Slower, and every attempt is logged by the application as a real connection. Noisy.

WHAT IT DOES

Sends UDP datagrams. An ICMP port-unreachable means closed; a reply means open; silence is ambiguous (open|filtered).

WHEN TO USE

Always at least once — DNS (53), SNMP (161), NTP (123), DHCP (67/68) and TFTP (69) only exist on UDP. Forgotten SNMP with a default community string is a classic finding.

TRADE-OFF

Slow by design (no acknowledgements), so scope it to the ports that matter.

TARGET192.168.1.10HOST DISCOVERY-snPORT SCAN-sS · -sT · -sUSERVICE + OS-sV · -ONSE SCRIPTSvuln · smb · httpOUTPUTnormal · XML · grep · -oA
Discover hosts → scan ports → identify services → run NSE scripts → save structured output

Commands & syntax

HOST DISCOVERY — who is alive
# ping sweep, no port scan
nmap -sn 192.168.1.0/24

# list-only, skip DNS resolution for speed
nmap -sn -n 10.0.0.0/24
CORE SCAN — ports and services
# SYN scan, all 65535 ports, service + OS detection
sudo nmap -sS -sV -O -p- 192.168.1.10

# faster: top 1000 ports, aggressive timing
nmap -sV -T4 192.168.1.10

# UDP (slow — scope it to the ports you care about)
sudo nmap -sU -p 53,123,161 192.168.1.10
NSE — what is actually vulnerable
# run the default safe script set
nmap -sV --script default 192.168.1.10

# category scans
nmap --script vuln 192.168.1.10
nmap --script smb-enum-shares -p 445 192.168.1.10
nmap --script http-headers -p 80,443 example.local
SAVE OUTPUT — never lose a scan
# -oA writes .nmap, .xml and .gnmap in one go
nmap -sV -oA scans/internal_10.10.10.5 10.10.10.5
KALI LINUX · errordex
kali@errordex:~/labs$ nmap -sV -T4 scanme.nmap.org

Starting Nmap 7.94SVN ( https://nmap.org ) at 2026-11-11 09:12 IST
Nmap scan report for scanme.nmap.org (45.33.32.156)
Host is up (0.031s latency).
Not shown: 996 closed tcp ports (reset)
PORT      STATE SERVICE    VERSION
22/tcp    open  ssh        OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13 (Ubuntu Linux; protocol 2.0)
80/tcp    open  http       Apache httpd 2.4.7 ((Ubuntu))
9929/tcp  open  nping-echo Nping echo
31337/tcp open  tcpwrapped
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 12.84 seconds

# Read this carefully:
#  22 + OpenSSH 6.6.1  → old, worth checking known issues
#  80 + Apache 2.4.7   → version is public, search CVEs for it
#  31337 tcpwrapped    → access is being filtered by TCP wrappers

Common mistakes

Scanning without permission

This is the one that ends careers. Even a port scan against infrastructure you do not own can be a criminal offence in India under the IT Act.

Using -T5 on real networks

Insane timing causes dropped packets, false "filtered" results and can knock over fragile devices. -T4 is the practical maximum.

Ignoring UDP

DNS (53), SNMP (161), NTP (123) and DHCP live on UDP — and SNMP with a default community string is a classic finding.

Trusting a single scan

Firewalls rate-limit. Scan again with different timing or from a different source before concluding a port is closed.

Not saving output

Re-scanning a large range because you forgot -oA wastes hours.

Assuming the version is accurate

Services lie, banners are faked, and reverse proxies mask the real backend.

Practice safely

Legal practice targets: scanme.nmap.org is maintained by the Nmap project specifically for this purpose — scanning it is authorised. For everything else, build a local lab: a Kali VM plus a Metasploitable VM on a host-only network gives you a realistic target range you fully own.

Structured learning: TryHackMe has a dedicated Nmap room that walks through every flag interactively. Hack The Box machines expect Nmap fluency from the first box.

Legal note. Only use Nmap on systems you own or have explicit written permission to test. In India, unauthorised access is punishable under sections 43 and 66 of the IT Act, 2000. Every example on this page assumes a lab environment.

Related