π€ AI Prompts Cheatsheet
Priya Nair — Prompt Engineering Expert
What is Nmap?
Nmap, short for Network Mapper, is a powerful open-source tool for network discovery and security auditing. It is widely used by security analysts and penetration testers to discover hosts and services on a computer network, thus creating a ‘map’ of the network. Nmap is also used to detect security risks and vulnerabilities in networks.
Installation
Nmap can be installed on multiple platforms, including Windows, Linux, and macOS. Below are the installation instructions for each:
- Windows: Download the Nmap installer from the official Nmap website and run it.
- Linux: Use the package manager, e.g., for Ubuntu, run
sudo apt-get install nmap. - macOS: Use Homebrew to install Nmap with
brew install nmap.
Basic Syntax
The basic syntax for Nmap is:
nmap [options] [target]
Where options are flags that modify the behavior of Nmap, and target is the IP address or hostname of the device you want to scan.
Discovery
Discovery scans help identify live hosts and networking issues on the local network.
- Ping Scan: This identifies which hosts are online.
nmap -sn 192.168.1.0/24
This command will perform a ping scan on the specified subnet.
Scanning
This includes port scanning and service version detection.
- Port Scan: Basic command to scan top 1000 ports.
nmap 192.168.1.1
- Service Version Detection: Identifies services running on open ports.
nmap -sV 192.168.1.1
Exploitation
Nmap can help identify potential vulnerabilities by scanning for specific services.
- Scripting Engine: Use default scripts for vulnerability checks.
nmap --script=vuln 192.168.1.1
Analysis
Analyzing scan results is crucial for recognizing patterns of vulnerabilities.
- Output to XML: Enables compatibility with other security tools.
nmap -oX scan_result.xml 192.168.1.1
Evasion
Obscuring scans to avoid detection by IDS systems or firewalls.
- Fragmentation: Splits packets to bypass filters.
nmap -f 192.168.1.1
Reporting
Generate human-readable reports based on Nmap output.
- Output to HTML: Creates visually appealing reports.
nmap -oA output_name 192.168.1.1
Quick Reference Table
| Flag | Description |
|---|---|
| -sP | Ping scan (no port scan) |
| -sV | Service version detection |
| -oX | Output in XML format |
| -f | Fragment packets |
| -A | Enable OS detection, version detection, script scanning, and traceroute |
Pro Tips
- Use -Pn if you want to treat all hosts as online, useful for firewalls.
- Combine options (e.g.,
nmap -sP -O -sV 192.168.1.0/24) for comprehensive scans.
Real-World Examples
Performing a basic scan of a web server might look like:
nmap -A -p 80,443 example.com
This command scans with OS and version detection on ports 80 and 443 to see if the service is vulnerable.