🤖 AI Prompts Cheatsheet
Priya Nair — Prompt Engineering Expert
What is Nmap?
Nmap (Network Mapper) is a powerful open-source tool for network discovery and security auditing. It’s widely used by penetration testers and network administrators to discover hosts and services on a computer network, thus creating a ‘map’ of the network.
Installation
Nmap can be installed on various platforms such as Windows, Linux, and macOS. Here’s how to install it on different operating systems:
- Windows: Download the installer from the Nmap official site.
- Linux: Use your package manager. For example, on Ubuntu, use
sudo apt install nmap. - macOS: Use Homebrew with the command
brew install nmap.
Basic Syntax
The basic syntax for Nmap is:
nmap [options] [targets]
Discovery
Use Nmap for discovering devices and services on a network.
Ping Scan
nmap -sn 192.168.1.1/24
This command performs a ping scan, which tells you which of your devices are currently online.
Service Discovery
nmap -sV 192.168.1.1
This will attempt to determine the version of the service running on open ports.
Scanning
In this section, we will cover how to perform different types of scanning.
TCP Connect Scan
nmap -sT 192.168.1.1
Stealth Scan
nmap -sS 192.168.1.1
The -sS option is used for a stealth SYN scan, which is less likely to be detected by intrusion detection systems.
Exploitation
While Nmap’s primary purpose is not exploitation, it can be useful in identifying vulnerable services.
Service Version Detection
nmap -sV --script vuln 192.168.1.1
This not only detects the service version but also runs vulnerability scripts related to that service.
Analysis
Once you have completed a scan, you can analyze the results using Nmap.
Output Formats
nmap -oN output.txt 192.168.1.1
Save output in a readable text format.
nmap -oX output.xml 192.168.1.1
Save output in an XML file for better data manipulation.
Evasion
Sometimes, Nmap can be detected by intrusion detection systems. Use the following techniques to minimize this:
Fragmentation
nmap -f 192.168.1.1
This sends fragmented packets, making it harder for IDS to analyze the traffic.
Decoy Scan
nmap -D RND:5 192.168.1.1
This command uses decoys to confuse the target’s logs about the actual scanning source.
Reporting
After complete analysis, it’s imperative to report your findings.
HTML Report
nmap -oX report.xml 192.168.1.1
Convert your XML output into HTML using xsltproc for better visualization.
Quick Reference Table
| Flag | Description |
|---|---|
| -sn | Ping Scan |
| -sV | Service Version Detection |
| -sS | SYN Stealth Scan |
| -oN | Output to a text file |
| -f | Fragment packets |
Pro Tips
- Use the -p option: Specify ports to scan
-p 22,80,443. - Rate Limiting: Use
--max-rate 100to avoid detection. - Use the timing template: If you need speed, use
-T4to speed up the scan.
Real-World Examples
For standard visualization, perform a fast scan with service version checking:
nmap -sV -T4 192.168.1.0/24
For determining firewall rules, use:
nmap -p 1-65535 -sA 192.168.1.1