0% found this document useful (0 votes)
21 views7 pages

Nmap Overview and Usage Guide

Uploaded by

o422187
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views7 pages

Nmap Overview and Usage Guide

Uploaded by

o422187
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1. What is Nmap?

· Definition: A free and open-source network scanner used for network


discovery and security auditing.

· Primary Purpose: To discover hosts and services on a computer network by


sending packets and analyzing the responses.

· Common Uses:

· Network Inventory: Discovering what devices (servers, printers, routers,


etc.) are on your network.

· Service Discovery: Identifying what services (HTTP, SSH, FTP, etc.) are
running on those devices and on which ports.

· Version Detection: Determining the application name and version number


of a service.

· OS Fingerprinting: Guessing the operating system running on a target


host.

· Security Auditing: Identifying potential vulnerabilities by finding open ports


and known service versions.

2. How Nmap Works (The Core Concepts)

Port States

Nmap categorizes ports into one of six states:

· Open: An application is actively accepting connections on this port.


· Closed: The port is accessible (the host is up), but no application is listening
on it.

· Filtered: A firewall, filter, or network obstacle is blocking the port,


preventing Nmap from determining if it is open or closed.

· Unfiltered: The port is accessible, but Nmap cannot determine if it is open


or closed. (Used mainly for ACK scan).

· Open|Filtered: Nmap cannot determine if the port is open or filtered


(common in UDP, IP Proto, FIN, NULL, and Xmas scans).

· Closed|Filtered: Nmap cannot determine if the port is closed or filtered.

Scan Types (The -s Flags)*

Nmap uses different TCP/IP techniques to probe ports.

· -sS (TCP SYN Scan): The default and most popular scan. It’s fast, stealthy
because it doesn’t complete the TCP handshake. Often called a “half-open”
scan.

· -sT (TCP Connect Scan): The default TCP scan when SYN scan is not an
option (e.g., without raw packet privileges). It completes the full TCP
handshake, making it louder and slower.

· -sU (UDP Scan): Scans for open UDP ports. Much slower than TCP scans
because UDP is connectionless.

· -sA (TCP ACK Scan): Used to map out firewall rulesets. It helps determine if
a firewall is stateful or not.

· -sN, -sF, -sX (Stealth Scans):

· NULL (-sN): Sends a packet with no flags set.

· FIN (-sF): Sends a packet with the FIN flag set.

· Xmas (-sX): Sends a packet with the FIN, PSH, and URG flags set (lights up
like a Christmas tree).

· These are designed to bypass primitive firewalls but often don’t work
against modern systems.
3. Essential Nmap Commands & Syntax

Basic Syntax

```bash

Nmap [ <Scan Type> ] [ <Options> ] { <target specification> }

```

Where a target can be an IP address ([Link]), a range ([Link]-


100), a subnet ([Link]/24), or a hostname ([Link]).

Common & Useful Command Examples

1. Basic TCP Scan:

```bash

Nmap [Link]

```

Scans the 1000 most common TCP ports on the target.

2. Scan a Specific Port or Range:

```bash

Nmap -p 80 [Link]

Nmap -p 80,443,22 [Link]

Nmap -p 1-1000 [Link]

Nmap -p- [Link]

```
-p- scans all 65,535 ports.

3. Service and Version Detection:

```bash

Nmap -sV [Link]

```

Probes open ports to determine the service and version information.


Extremely useful.

3. OS Detection:

```bash

Nmap -O [Link]

```

Attempts to guess the target’s operating system. Requires root/Admin


privileges.

4. Aggressive Scan:

```bash

Nmap -A [Link]

```

A “kitchen sink” option that enables OS detection (-O), version detection (-


sV), script scanning (-sC), and traceroute. Powerful but noisy.

5. Scan a Whole Network:

```bash

Nmap [Link]/24

```

Discovers all live hosts and their common ports on a /24 subnet.

6. Ping Scan (Host Discovery Only):

```bash

Nmap -sn [Link]/24

```
Doesn’t scan ports; only discovers which hosts are up. Like a sophisticated
ping sweep.

7. UDP Scan:

```bash

Nmap -sU -p 53,161,123 [Link]

```

Scans for specific common UDP services (DNS, SNMP, NTP). Requires
root/Admin privileges and is slow.

4. Advanced Features: Nmap Scripting Engine (NSE)

The NSE allows users to write (or use pre-existing) scripts to automate a wide
variety of networking tasks.

· -sC: Runs the default set of NSE scripts. These are common, safe, and
informative scripts.

· --script: Runs a specific category or script.

```bash

Nmap –script=http-title [Link] # Runs only the `http-title` script

Nmap –script=vuln [Link] # Runs all scripts in the “vuln”


category

Nmap –script “safe and http-*” [Link] # Runs all safe scripts starting
with “http-“

```

· Script Categories: vuln, safe, intrusive, discovery, auth, brute, etc.

5. Timing and Performance


Nmap uses timing templates (-T0 to -T5) to control the speed/stealth of the
scan.

· -T0 (Paranoid): Extremely slow, used for IDS evasion.

· -T1 (Sneaky): Very slow.

· -T2 (Polite): Slows down to use less bandwidth.

· -T3 (Normal): The default.

· -T4 (Aggressive): Assumes you are on a fast, reliable network.

· -T5 (Insane): Extremely fast; may overwhelm networks or miss ports.

Pro Tip: Use –min-parallelism and –max-parallelism for finer control than the -
T flags.

6. Output Formats

· -oN <file>: Normal output to a file.

· -oX <file>: XML output, useful for importing into other tools.

· -oG <file>: Grepable output (older format, still useful for command-line
parsing).

· -oA <basename>: Outputs in all three major formats (Normal, XML,


Grepable) at once.

7. Important Legal and Ethical Notes


· Permission is Crucial: Only scan networks and systems that you own or
have explicit, written permission to test. Unauthorized scanning is illegal in
many jurisdictions and is a violation of computer fraud laws.

· Stealth is Relative: While some scans are “stealthier” than others, modern
Intrusion Detection Systems (IDS) like Suricata or Snort can detect most
Nmap scan types.

· It’s a Recon Tool: Nmap is primarily an information-gathering tool. It tells


you what and where something is. It is not typically an exploitation tool,
though its scripts can identify potential vulnerabilities.

Summary Cheat Sheet

```bash

# The “Go-To” Commands

Nmap -sV -sC -O TARGET # Standard detailed scan

Nmap -A TARGET # Aggressive scan (same as above + traceroute)

Nmap -p- -sV TARGET # Full port scan with service detection

# Discovery

Nmap -sn [Link]/24 # Find live hosts only

Nmap –script discovery TARGET # Run various discovery scripts

# Stealth & Speed

Nmap -T4 -F TARGET # Fast scan of top 100 ports

Nmap -sS TARGET # Default SYN scan (requires sudo)

```

Common questions

Powered by AI

A UDP scan (-sU) would be selected over a TCP scan when the objective is to detect open UDP ports, particularly for services like DNS, SNMP, and NTP which rely on UDP. The challenges with UDP scans include their slowness due to UDP's connectionless nature, requiring additional processing time to determine whether a port is open, closed, or filtered. It often relies on ICMP port unreachable messages to infer closed ports, and many network devices limit ICMP responses to mitigate network load, leading to false negatives where ports appear closed. Additionally, UDP scans require root privileges, making them less suitable in environments with restricted permissions .

The aggressive scanning option (-A) in Nmap consolidates multiple scanning techniques into one command, providing comprehensive information compared to a standard scan. It stands out by enabling OS detection (-O), version detection (-sV), script scanning (-sC), and traceroute all at once. This "kitchen sink" approach yields detailed information about the target's services, operating system, and potential network paths, delivering extensive reconnaissance data. However, it is noisier and more likely to trigger security alarms due to the multiple simultaneous activities, contrasting with a standard scan that might only perform basic port checks with minimal noise .

Port scanning, using tools like Nmap, plays a pivotal role in cybersecurity strategies from both defensive and offensive perspectives. Defensively, it assists network administrators in discovering and cataloging open ports, enabling them to identify and close unnecessary or unsecured services, thereby reducing attack surfaces and enhancing network defenses. Nmap’s OS detection and service versioning also help in vulnerability management by pinpointing outdated software. Offensively, from an ethical hacker's perspective, port scanning allows for reconnaissance, identifying potential vectors for attack by mapping network services and their configurations in target environments. It supports penetration testing by simulating potential threat actions to strengthen an organization's security posture. Both perspectives underscore the importance of understanding network structures and service vulnerabilities to prevent unauthorized access .

In network inventory management, Nmap effectively discovers hosts and services, providing a detailed map of active devices and their configurations such as IPs and open ports, which is crucial for maintaining updated network inventories and efficiently managing resources. Its ability to perform service discovery aids in ensuring that network services are optimally allocated and monitored . In security auditing, Nmap excels at identifying potential vulnerabilities by detecting open ports, outdated services, or exploitable weaknesses through version detection and OS fingerprinting. However, limitations arise from the legal and ethical constraints of scanning non-authorized networks and the potential for detection by IDS, which can hinder stealth operations. Additionally, some modern systems use advanced firewalls that can render certain Nmap techniques less effective, such as stealth scans .

The Nmap Scripting Engine (NSE) significantly enhances Nmap by allowing users to automate a wide range of networking tasks beyond basic host discovery and port scanning. It supports custom scripts that can execute various functions such as vulnerability detection, network discovery, and security auditing. NSE scripts are categorized into several types, including 'vuln' for detecting vulnerabilities, 'safe' for non-invasive tasks, 'intrusive' for potentially disruptive operations, 'discovery' for additional network information, 'auth' for authentication-related tasks, and 'brute' for brute-force attacks. Users can run the default set of NSE scripts with the -sC option or select specific scripts or categories using --script .

Nmap's timing and performance settings, controlled using the -T0 to -T5 flags, adjust the speed of scanning operations, impacting detection risk and scan thoroughness. In high-security environments, selecting an appropriate timing template is crucial. -T0 (Paranoid) and -T1 (Sneaky) are slower but decrease the likelihood of detection by Intrusion Detection Systems (IDS), making them suitable for evasion but impractical for large-scale scanning. -T4 (Aggressive) and -T5 (Insane) increase the scan speed, but can overwhelm networks and increase detection risk due to the rapid packet transmission, which is often detected as unusual activity. Balancing scan speed with network load and security is essential to avoid triggering alarms or affecting network performance .

The TCP SYN Scan (-sS) is considered faster and stealthier than the TCP Connect Scan (-sT) because it does not complete the TCP handshake. Known as "half-open" scanning, a SYN scan only sends a SYN packet and waits for a SYN-ACK response before sending a RST, preventing the session from being fully established. This method reduces the chance of detection by firewalls or logging mechanisms. In contrast, the TCP Connect Scan completes the full TCP handshake, making it noisier and slower, which can draw attention from intrusion detection systems .

Nmap's diverse output formats—Normal (-oN), XML (-oX), and Grepable (-oG)—enhance data analysis workflows by providing flexibility in how scan results are utilized in cybersecurity operations. Normal output is straightforward for human readability, useful for individual analysis and quick checks. XML format supports structured data, allowing integration with automated security systems and vulnerability management tools, enhancing cross-platform data sharing and integration. Grepable outputs serve as legacy support, assisting command-line parsing and quick filtering of scan results. These capabilities ensure that Nmap's findings can be efficiently processed, visualized, and acted upon, facilitating comprehensive security protocols and responses based on detailed and accessible data .

Ethical considerations for using Nmap include ensuring that scans are only conducted on networks and systems for which the user has explicit, written permission. Unauthorized scanning can breach privacy laws and constitute a violation of computer fraud laws, leading to legal consequences. Users must also be aware that even "stealthy" scans can be detected by modern Intrusion Detection Systems (IDS), which may generate alerts. It's crucial to understand that Nmap is a tool for reconnaissance, not exploitation. Thus, responsible usage aligns with ethical hacking practices, aiding in network security assessments legally and transparently .

Nmap categorizes ports into six states: Open, Closed, Filtered, Unfiltered, Open|Filtered, and Closed|Filtered. An 'Open' port has an application actively accepting connections. A 'Closed' port is accessible but has no listening application, indicating that the host is up. 'Filtered' implies that a firewall or filter blocks the port, preventing Nmap from determining its state. 'Unfiltered' ports are accessible, but Nmap cannot determine if they are open or closed, used primarily in ACK scans. 'Open|Filtered' and 'Closed|Filtered' occur when Nmap cannot ascertain whether the ports are open/filtered or closed/filtered, respectively, often seen in particular scan types like UDP or FIN scans .

You might also like