Conducting Nmap Scans
Basic Nmap Scan
To conduct a basic Nmap scan, you can use the following command:
nmap <target_ip_or_domain>
This will perform a TCP connect scan on the target, revealing the open ports and running services.
Advanced Nmap Scan Options
Nmap offers a wide range of options to customize the scan and gather more detailed information. Some common advanced options include:
-sV
: Probe open ports to determine service/version info
-sS
: TCP SYN scan (stealthier than the default TCP connect scan)
-sU
: UDP scan
-sC
: Use default nmap scripts for further enumeration
-p-
: Scan all ports (instead of the most common 1000 ports)
-oA <basename>
: Output all major formats with a base filename
Here's an example of an advanced Nmap scan:
nmap -sS -sV -p- -oA nmap_scan_results 192.168.1.1/24
This command will perform a SYN scan, probe open ports to determine service and version information, scan all 65,535 ports, and save the output in all major formats with the base filename "nmap_scan_results".
Nmap Scripting Engine (NSE)
Nmap's Scripting Engine (NSE) allows you to extend the functionality of Nmap by running custom scripts. These scripts can be used for a variety of tasks, such as:
- Vulnerability detection
- Service and version detection
- Brute-force attacks
- Enumeration of specific protocols (e.g., SMB, SNMP, etc.)
To run an NSE script, you can use the -script
option followed by the script name. For example:
nmap -sV --script=http-title 192.168.1.1
This command will run the http-title
script, which retrieves the title of the web page running on the target system.
Saving Nmap Scan Data
It is important to save the Nmap scan data for further analysis and reporting. Nmap supports several output formats, including:
- Normal: Human-readable output
- Greppable: Line-based output for easy parsing
- XML: Structured data for integration with other tools
- Script Kiddie: ASCII-art style output
To save the scan data, you can use the -oA
option followed by a base filename. For example:
nmap -sV -p- -oA nmap_scan 192.168.1.1/24
This will save the scan results in all major formats (Normal, Greppable, and XML) with the base filename "nmap_scan".