πŸ›  Security Tool Cheatsheet

Sarah Chen — SOC Analyst & Tool Specialist

{
“title”: “Security Tool Cheatsheet: Nmap”,
“content”: “

What is Nmap?

Nmap (Network Mapper) is a powerful open-source tool designed for network discovery and security auditing. It is commonly used by security analysts and penetration testers to map out networks, discover hosts and services, and identify vulnerabilities.

Installation

Nmap can be installed on various platforms, including Windows, macOS, and Linux. Use the following commands for installation:

# For Ubuntu/Debian\nsudo apt install nmap\n\n# For CentOS/RHEL\nsudo yum install nmap\n\n# For macOS (using Homebrew)\nbrew install nmap\n\n# For Windows download from:\nhttps://nmap.org/download.html

Basic Syntax

The basic syntax for using Nmap is as follows:

nmap [options] [target]

Discovery

Ping Scan

To quickly check which hosts are up on a network:

nmap -sn 192.168.1.0/24

Service Version Detection

To discover what services are running on open ports:

nmap -sV 192.168.1.1

Scanning

Full TCP Scan

To perform a complete TCP scan and identify open ports:

nmap -sT 192.168.1.1

UDP Scan

To scan for open UDP ports:

nmap -sU 192.168.1.1

Exploitation

Enable OS Detection

To determine the operating system of a target:

nmap -O 192.168.1.1

Script Scanning

To use Nmap scripts to detect vulnerabilities and exploits:

nmap --script=vuln 192.168.1.1

Analysis

Output Formatting

To save scan results in various formats:

Flag Description
-oN Normal output file
-oG Grepable output
-oX XML output

Evasion

Fragment Packets

To evade firewalls and IDS by fragmenting packets:

nmap -f 192.168.1.1

Change Source Port

Change the source port to avoid detection:

nmap --source-port 12345 192.168.1.1

Reporting

Generate Report

To generate a comprehensive HTML report:

nmap -oX report.xml 192.168.1.1

Quick Reference Table

Flag Description
-sn Ping scan
-sV Service version detection
-sT TCP connect scan
-sU UDP scan
-O OS detection
–script Use scripts
-oN Normal output
-oG Grepable output
-oX XML output
-f Fragment packets
–source-port Change source port

Pro Tips

  • Use nmap -p- to scan all 65535 ports.
  • Combine options for advanced scanning, e.g., nmap -sS -sV -O 192.168.1.1.

Real-World Examples

Here are some examples of how to use Nmap effectively:

Example 1: Network Inventory

To create an inventory of all live hosts and their open ports:

nmap -sP 10.0.0.0/24 –oN nmap_live_hosts.txt\n# Use additional flags for detailed port and service discovery as needed

Example 2: Vulnerability Assessment

To find vulnerabilities using Nmap Scripting Engine:

nmap --script vuln 192.168.1.1 --script-args unsafe=1\n# Combine with port scanning flags for a more thorough check

“,
“keywords”: [“Nmap”, “network scanning”, “security tool”, “vulnerability assessment”]