GO KALI FREE

Nmap

Information Gathering

Beginnermedium risk

Network Mapper - A powerful open-source tool for network discovery and security auditing. Nmap uses raw IP packets to determine what hosts are available on the network, what services those hosts are offering, and what operating systems they are running.

Installation

apt-get install nmap

Basic Syntax

nmap [Scan Type] [Options] {target specification}

Quick Facts

Full Name
Network Mapper
License
GNU GPL v2
Author
Gordon Lyon (Fyodor)
Written In
C, C++, Python, Lua
Platforms
Linux, Windows, macOS, Termux
Category
Network Scanner
First Release
1997
Scripting Engine
NSE (Nmap Scripting Engine)

Tool Overview

Nmap (Network Mapper) is a free, open-source utility for network discovery and security auditing. It uses raw IP packets to identify active hosts, open ports, running services, and operating systems across any TCP/IP network.

Created by Gordon Lyon in 1997, Nmap has become the industry-standard tool for network reconnaissance. Security professionals, system administrators, and penetration testers rely on it for asset discovery, vulnerability assessment, and compliance verification.

The Nmap Scripting Engine (NSE) extends core scanning with over 700 Lua scripts for automated vulnerability detection, brute-force testing, and service enumeration. Combined with Zenmap, its graphical interface, Nmap serves both beginners and advanced users.

Common Commands

nmap 192.168.1.1Basic scan of a single IP address
nmap -sV 192.168.1.1Probe open ports to determine service/version info
nmap -sn 192.168.1.0/24Ping scan - disable port scan (discover active hosts)
nmap -p 80,443 192.168.1.1Scan specific ports (80 and 443)
nmap -sS 192.168.1.1TCP SYN scan (stealth scan)
nmap -sT 192.168.1.1TCP connect scan
nmap -sU 192.168.1.1UDP scan
nmap -p- 192.168.1.1Scan all 65535 ports
nmap -O 192.168.1.1Enable OS detection
nmap -A 192.168.1.1Aggressive scan (OS, version, script scanning, traceroute)
nmap -sS -sV -O -p- -T4 192.168.1.1Comprehensive fast scan (SYN, version, OS, all ports, T4 timing)
nmap --script vuln 192.168.1.1Run all vulnerability scanning scripts
nmap --script=http-enum 192.168.1.1Enumerate common web application directories and files
nmap --script=smb-vuln* 192.168.1.1Run all SMB vulnerability scripts
nmap -sV --script=banner 192.168.1.1Grab banners for detected services

Step-by-Step Guide

  1. 1Open a terminal in Kali Linux
  2. 2Identify your target IP address or hostname
  3. 3Start with a basic scan: nmap <target>
  4. 4Review the output to see open ports
  5. 5Use -sV flag to detect service versions if needed
  6. 6For deeper analysis, use -A flag (aggressive scan)
  7. 7Save results with -oN filename.txt for later review

Warnings

Use Cases

Host Discovery

Identify active devices on any network segment. Find live hosts before deeper scanning.

Port Scanning

Map open ports on target systems. Detect TCP/UDP services accepting connections.

Service Detection

Fingerprint running services and version numbers. Identify outdated software.

OS Detection

Determine operating system through TCP/IP stack fingerprinting.

Vulnerability Scanning

Run NSE scripts to detect known CVEs and misconfigurations.

Network Mapping

Visualize entire network topologies. Document infrastructure layout.

Firewall Enumeration

Identify firewall rules and packet filtering behavior using different scan types and response analysis.

SSL/TLS Assessment

Evaluate encryption configurations, certificate validity, and supported cipher suites on web servers.

Default Credential Detection

Test common default usernames and passwords on discovered services using NSE brute-force scripts.

DNS Enumeration

Discover DNS records, zone transfers, and subdomains associated with target domains.

Network Inventory

Build a comprehensive asset database of all devices, operating systems, and services across the infrastructure.

Shadow IT Detection

Find unauthorized devices and services connected to the network that bypass official IT management.

Key Features

People Also Ask

What is the difference between Nmap SYN scan and TCP connect scan?

A SYN scan (-sS) sends SYN packets without completing the TCP handshake, making it faster and stealthier — it is the default when running as root. A TCP connect scan (-sT) completes the full three-way handshake using the OS connect() call, which is more reliable but slower and fully logged by the target. Use -sS for stealthy authorized engagements; use -sT only when -sS is unavailable (non-root).

How long does a full Nmap port scan take?

A default scan of the top 1000 ports on a single host completes in 1-5 seconds. A full port scan (-p-) covering all 65535 ports takes 2-10 minutes per host depending on the timing template (-T0 through -T5) and network conditions. Aggressive timing (-T5) is faster but more likely to miss ports or trigger IDS alerts.

Can Nmap detect operating systems?

Yes. Use nmap -O [target] for OS detection. Nmap analyzes TCP/IP stack responses, TCP window sizes, IP ID sequences, and other fingerprinting techniques to determine the target's operating system and version with high accuracy. OS detection requires at least one open and one closed port on the target.

What is the Nmap Scripting Engine (NSE)?

NSE is a Lua-based framework that extends Nmap's scanning capabilities with over 700 scripts. Scripts automate vulnerability detection (vuln category), brute-force testing (brute category), network discovery (discovery category), and more. Run scripts with nmap --script [category or script name] [target]. Categories include auth, broadcast, brute, default, discovery, dos, exploit, external, fuzzer, intrusive, malware, safe, version, and vuln.

Is Nmap legal to use?

Nmap itself is legal software. However, scanning networks or systems without explicit written permission from the owner is illegal in most jurisdictions. Unauthorized scanning violates laws like the CFAA (US), Computer Misuse Act (UK), and similar legislation worldwide. Always obtain proper authorization before performing any network scans.

Does Nmap work on firewalled networks?

Yes, but with limitations. Nmap can use fragmentation (-f), decoys (-D), source port spoofing (--source-port), and idle scans (-sI) to bypass some firewall rules. However, stateful firewalls that track connections will block many evasion techniques. Use nmap -sN (Null scan) or -sF (FIN scan) to bypass stateless packet filters.

What is the difference between -sS and -sT?

nmap -sS (SYN scan) sends SYN packets without completing the TCP handshake — it is faster, stealthier, and the default scan when running as root. nmap -sT (TCP connect scan) completes the full three-way handshake using the OS connect() call, making it more reliable but slower and fully logged by the target. Use -sS for stealth; use -sT only when -sS is unavailable (non-root).

Can Nmap scan IPv6 addresses?

Yes. Use nmap -6 [target] to scan IPv6 addresses. Nmap supports IPv6 scanning for most scan types including SYN, connect, and UDP scans. IPv6 scanning is especially useful in modern enterprise networks and cloud environments that use dual-stack or IPv6-only configurations.

Learning Path

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5

Related Tools

Wireshark

Sniffing & Spoofing

Deep packet inspection and protocol analysis. Inspect the traffic Nmap discovers on open ports.

Metasploit

Exploitation

Exploitation framework that uses Nmap results to launch attacks against discovered services.

Nikto

Web Application

Web server scanner that complements Nmap's port scanning with web vulnerability detection.

Gobuster

Web Application

Directory and subdomain brute-forcer for web targets identified by Nmap.

SQLMap

Web Application

SQL injection detection and exploitation for web apps found via Nmap port scanning.

Hydra

Password Attacks

Online password brute-forcer for services Nmap identifies as open.

SMBClient

Information Gathering

SMB/CIFS client for accessing shared resources on Windows and Samba systems. Use after Nmap discovers SMB ports (445/139) to enumerate shares, transfer files, and extract data.

Nmap Vulners

Vulnerability Scanning

NSE script that cross-references detected service versions against the Vulners vulnerability database for known CVEs.

Masscan

Information Gathering

Ultra-fast port scanner that complements Nmap by quickly identifying live ports before detailed Nmap analysis.

Enum4linux

Information Gathering

SMB/Samba enumeration tool for detailed Windows domain information after Nmap identifies SMB ports.

Frequently Asked Questions

What is Nmap tool?

Nmap (Network Mapper) is a free, open-source network scanner used for host discovery, port scanning, service detection, and OS fingerprinting. Created by Gordon Lyon in 1997, it sends raw IP packets to identify active devices, open ports, and running services on any TCP/IP network.

What is Nmap tool used for?

Nmap is used for five primary tasks: host discovery (finding live devices), port scanning (identifying open ports), service detection (fingerprinting applications and versions), OS detection (determining operating systems), and vulnerability scanning via NSE scripts. Network administrators use it for security audits, while penetration testers use it to map attack surfaces before exploitation with tools like Metasploit.

How to use Nmap tool?

Install Nmap using your package manager (apt-get install nmap on Kali Linux), then run nmap followed by a target IP address or hostname. Start with a basic scan: nmap 192.168.1.1. Add flags like -sV for service detection, -O for OS detection, and -A for aggressive scanning. For subnet scans, use CIDR notation: nmap -sn 192.168.1.0/24. Practice in a lab environment before scanning live networks.

Is Nmap legal?

Nmap itself is legal software. However, scanning networks or systems without explicit written permission from the owner is illegal in most jurisdictions. Unauthorized scanning violates laws like the CFAA (US), Computer Misuse Act (UK), and similar legislation worldwide. Always obtain proper authorization before performing any network scans. Nmap is designed for legitimate security testing, network administration, and educational purposes.

Why is Nmap used in cybersecurity?

Nmap is the foundation of network reconnaissance in cybersecurity. It helps professionals discover assets, detect vulnerabilities, and assess security posture. The Nmap Scripting Engine (NSE) enables automated vulnerability detection, and results integrate seamlessly with exploitation frameworks like Metasploit. Both offensive (penetration testing) and defensive (security monitoring) teams depend on Nmap for network visibility.

What are the most common Nmap commands?

Essential Nmap commands include: nmap [target] for basic scanning, nmap -sV [target] for service detection, nmap -sn [target] for host discovery, nmap -O [target] for OS detection, nmap -A [target] for aggressive scanning, and nmap -p- [target] to scan all 65535 ports. For vulnerability scanning, use nmap --script vuln [target]. Save results with -oA for all formats or -oN for normal output.

Can Nmap run on Windows?

Yes, Nmap runs on Windows, Linux, and macOS. The Windows installer from nmap.org includes both the command-line tool and Zenmap, a graphical user interface for visualization and comparison. Nmap for Windows provides identical functionality to the Linux version. Android users can run Nmap through Termux. All platforms support the full Nmap Scripting Engine.

Is Nmap free?

Yes, Nmap is completely free and open source under the GNU General Public License (GPL). Download it from nmap.org without any cost. The Nmap Scripting Engine, Zenmap GUI, and all 700+ NSE scripts are included. Nmap is maintained by an active community of developers and security researchers, ensuring continuous updates and comprehensive documentation.

Are there online Nmap tools?

While web-based Nmap alternatives exist (such as online port scanners), they cannot replace Nmap's full capabilities. Online tools are limited to basic port scanning from their server's IP and cannot perform OS detection, NSE scripts, or stealth scans. For serious penetration testing, install Nmap locally using apt-get install nmap on Kali Linux or download from nmap.org. Practice in lab environments like HackTheBox or TryHackMe to learn safely.

Can Nmap detect operating systems?

Yes. Use nmap -O [target] for OS detection. Nmap analyzes TCP/IP stack responses, TCP window sizes, IP ID sequences, and other fingerprinting techniques to determine the target's operating system and version with high accuracy.

What is Nmap NSE?

Nmap Scripting Engine (NSE) is a Lua-based framework that extends Nmap's scanning capabilities with over 700 scripts. NSE scripts automate vulnerability detection (vuln category), brute-force testing (brute category), network discovery (discovery category), and more. Scripts are organized into categories: auth, broadcast, brute, default, discovery, dos, exploit, external, fuzzer, intrusive, malware, safe, version, and vuln. Run scripts with nmap --script [category or script name] [target].

How fast can Nmap scan?

Nmap speed depends on the timing template used (-T0 through -T5). T0 (Paranoid) takes hours per host; T3 (Normal) is the default; T5 (Insane) scans as fast as possible but may miss ports. A basic scan of 1000 ports on a single host typically completes in 1-5 seconds. Full port scans (-p-) take 2-10 minutes per host depending on timing and network conditions.

Does Nmap work on firewalled networks?

Yes, but with limitations. Nmap can use fragmentation (-f), decoys (-D), source port spoofing (--source-port), and idle scans (-sI) to bypass some firewall rules. However, stateful firewalls that track connections will block many evasion techniques. Use nmap -sN (Null scan) or -sF (FIN scan) to bypass stateless packet filters. Stateful inspection firewalls require more advanced techniques or direct network access.

What is the difference between -sS and -sT?

nmap -sS (SYN scan) sends SYN packets without completing the TCP handshake — it's faster, stealthier, and the default scan when running as root. nmap -sT (TCP connect scan) completes the full three-way handshake using the OS's connect() call, making it more reliable but slower and fully logged by the target. Use -sS for stealth; use -sT only when -sS isn't available (non-root).

Can Nmap scan IPv6 addresses?

Yes. Use nmap -6 [target] to scan IPv6 addresses. Nmap supports IPv6 scanning for most scan types including SYN, connect, and UDP scans. IPv6 scanning is especially useful in modern enterprise networks and cloud environments that use dual-stack or IPv6-only configurations.

What output formats does Nmap support?

Nmap supports four output formats: -oN (normal text), -oX (XML for import into Metasploit and other tools), -oG (greppable format for scripting), and -oA (all three formats simultaneously). XML output (-oX) is the most versatile for automated processing. Use -oA to save all formats at once for maximum flexibility in post-scan analysis.

How do I scan a specific port with Nmap?

Use -p [port number] to scan a specific port: nmap -p 80 192.168.1.1 scans only port 80. For multiple ports: nmap -p 80,443,8080 [target]. For port ranges: nmap -p 1-1024 [target]. For all ports: nmap -p- [target]. You can also use port names: nmap -p http [target].

What is an idle scan in Nmap?

An idle scan (nmap -sI zombie_host [target]) uses a third-party 'zombie' host to scan the target. The scan appears to come from the zombie rather than your IP, making it truly anonymous. The technique exploits predictable IP ID sequences on the zombie to determine port states. Find suitable zombies with nmap -O -sI [potential_zombie] [target].

How does Nmap integrate with Metasploit?

Nmap XML output (-oX) can be imported directly into Metasploit using the db_import command or db_nmap command. This allows Metasploit to automatically create hosts, services, and vulnerabilities from Nmap results. Workflow: nmap -sV -oX scan.xml [target] → msfconsole → db_import scan.xml → hosts → services → vulns.

Can Nmap scan through proxies?

Nmap has limited proxy support. For HTTP CONNECT proxies, use --proxies. For SOCKS4/SOCKS5 proxies, use --proxies socks4:// or socks5://. However, proxy scanning significantly limits available scan types — stealth scans, OS detection, and most NSE scripts won't work through proxies. Direct scanning is always preferred when possible.

Tags

#reconnaissance#network-scanning#port-scanning

Output Explanation

Nmap output shows: PORT (port number/protocol), STATE (open/closed/filtered), and SERVICE (what's running). "open" means the port accepts connections. "filtered" means a firewall is blocking. "closed" means no service is listening.

Ethical Usage Notice

This tool is designed for authorized security testing, educational purposes, and legitimate network administration only. Unauthorized access to computer systems is illegal.