Nmap Security Tool Cheatsheet

πŸ“± Mobile Security Tips

Sarah Chen — iOS Security Specialist

What is Nmap?

Nmap (Network Mapper) is an open-source tool used for network discovery and security auditing. It helps analysts discover hosts and services on a computer network, thus creating a ‘map’ of the network. Nmap can be used to detect operating systems, manage service upgrade schedules, and monitor host or service uptime.

Installation

To install Nmap, use the following commands based on your operating system:

  • For Ubuntu/Debian: sudo apt install nmap
  • For CentOS/RHEL: sudo yum install nmap
  • For macOS: brew install nmap

Basic Syntax

The basic syntax of Nmap is as follows:

nmap [options] [target]

Discovery

Discover hosts and services in the network:

nmap -sn 192.168.1.0/24

-sn: Perform a ping scan (no port scan).

Scanning

To scan ports and gather detailed service information:

nmap -sS -sV -O 192.168.1.1
Flag Description
-sS TCP SYN scan
-sV Service version detection
-O Operating system detection

Exploitation

To exploit a service running on an open port:

nmap --script  -p  

–script: Runs specific scripts against the target. Replace and accordingly.

Analysis

To save the scan result for later analysis:

nmap -oN scan_results.txt 192.168.1.1

-oN: Output scan results in a normal text file.

Evasion

To avoid detection by IDS/IPS:

nmap -f 192.168.1.1

-f: Fragment packets to evade intrusion detection systems.

Reporting

To generate an XML report for further processing:

nmap -oX scan_results.xml 192.168.1.1

-oX: Output results in XML format suitable for machine consumption.

Pro Tips

  • Use Nmap Scripting Engine: Utilize built-in scripts for vulnerabilities. Example: nmap --script vuln .
  • Parallel Scanning: Speed up the scan with the -Pn flag to skip host discovery.
  • Service Detection: Combine -sV with version detection for deeper insights.

Real-World Examples

For instance, to scan a specific network range quickly:

nmap - T4 -p 1-1000 -sS 192.168.1.0/24

This uses -T4 for faster execution, -p 1-1000 to limit the port range, and performs a -sS (SYN) scan.

Additionally, for security assessments, you might run:

nmap -p 22,80,443 --script http-enum -oN web_services.txt 192.168.1.1

This checks for HTTP services using the HTTP enumeration script and saves results in web_services.txt.