🤖 AI Prompts Cheatsheet
Daniel Osei — AI-Assisted Security Engineer
What is Nmap?
Nmap (Network Mapper) is a powerful open-source tool used for network discovery and security auditing. It is widely utilized by security analysts and penetration testers to assess vulnerabilities, detect active hosts, and gather detailed information about services and operating systems on networks.
Installation
Nmap can be installed on various operating systems, including Windows, Linux, and macOS. Follow these simple steps for installation:
- On Linux: Use your package manager, for instance,
sudo apt install nmap(Debian/Ubuntu) orsudo yum install nmap(CentOS). - On Windows: Download the installer from the Nmap website.
- On macOS: Use Homebrew:
brew install nmap.
Basic Syntax
The basic syntax for running Nmap is:
nmap [options] [target]
Discovery
Use Nmap for discovering hosts and services:
nmap -sn 192.168.1.0/24– Pings the specified subnet to discover live hosts.
Scanning
Identify open ports and services:
nmap -sS -p 1-65535– Performs a stealth scan to detect open TCP ports.nmap -sU -p 1-65535– Performs a UDP scan on the specified target.
Exploitation
Using Nmap’s scripting engine for vulnerability exploitation:
nmap --script vuln– Executes vulnerability detection scripts against the target.
Analysis
Perform in-depth analysis of services:
nmap -A– Enables OS detection, version detection, script scanning, and traceroute.
Evasion
Bypass firewall rules with stealth techniques:
nmap -D RND:10– Uses decoy scans to obfuscate the source of the scan.
Reporting
Export your scan results for documentation:
nmap -oN results.txt– Saves the scan output to a text file.nmap -oX results.xml– Saves the output in XML format for further processing.
Quick Reference Table
| Flag | Description |
|---|---|
| -sS | TCP SYN scan |
| -sU | UDP scan |
| -A | Aggressive scan (OS detection, version detection) |
| -oN | Output to a normal text file |
| –script | Enable Nmap scripts |
Pro Tips
Scan with Timing: Adjust timing with the -T option to control the speed and stealth of your scans.
Use Nmap Scripting Engine: Leverage scripts for specific protocols or vulnerabilities. It can save significant time in identifying risks.
Scan Multiple Targets: You can scan multiple IPs or ranges by separating them with commas or using CIDR notation.
Real-World Examples
Scenario 1: Discover all live hosts and their open ports on a local network:
nmap -sP 192.168.1.0/24
Scenario 2: Perform a full assessment including OS detection on a remote server:
nmap -A -p 1-1000 example.com
Scenario 3: Export results in XML for later analysis:
nmap -oX results.xml -sS 192.168.1.1