Using Nmap for Security Auditing
- sujosutech
- 8 hours ago
- 4 min read
Introduction
Nmap (Network Mapper) is a free, open-source tool used primarily for network discovery and security auditing. It is widely used by system administrators, network engineers, ethical hackers, and security professionals to identify what devices are running on a network, what services those devices are offering, what operating systems they are running, and whether they have any known vulnerabilities. It is used by penetration testers and ethical hackers to detect misconfigured systems, ensure network compliance and security posture and supports large-scale scans and automation. It is a free and open-source tool and can be downloaded from the official website - https://nmap.org.

Nmap Scripting Engine (NSE)
Nmap Scripting Engine or NSE is built into Nmap and uses scripts written in the Lua programming language. These scripts can perform a wide variety of tasks during a scan, from gathering detailed information about a host to actively probing for known vulnerabilities. The scripts are usually stored in /usr/share/nmap/scripts/ directory. The importance and utility of NSE can be depicted by the following characteristics of NSE:
Automation - Automates complex tasks that would take much longer manually.
Customization - Allows writing or modifying custom Lua scripts for automation.
Depth - Goes beyond surface-level scanning into deep service analysis.
Integration - Works seamlessly within the Nmap command structure.
Best practices and use cases in security auditing using Nmap
When conducting security audits, it is important to follow best practices to ensure thorough and effective assessments. Scans should be run from both inside and outside the network to evaluate firewall rules and exposure levels. Stealth scans, such as Nmap’s -sS option, can be utilized to perform low-profile reconnaissance without triggering intrusion detection systems. Scheduled scans can help maintain compliance and monitor changes in the network over time. Nmap Scripting Engine (NSE) can be leveraged to perform in-depth vulnerability assessments, including checks for known CVEs. For a more comprehensive audit, Nmap can be used with additional tools to cover web application vulnerabilities and broader security gaps.
Nmap serves a wide range of purposes in security auditing, making it an essential tool for network assessments. One of its primary uses is port scanning, which helps detect open ports and the services running on them. It also supports OS detection to identify the operating systems of target devices, along with version detection to determine the specific software and version numbers in use. Nmap can assist in testing firewall and IDS/IPS configurations by simulating traffic patterns to identify potential evasion paths. Its powerful scripting engine (NSE) enables vulnerability scanning by detecting known security issues. Additionally, Nmap is highly effective for building a network inventory by mapping all active devices and the services they offer. For compliance purposes, it can validate whether only the required ports and services are exposed, ensuring adherence to security policies.
Nmap output formats for reporting
Format | Flags | Use Case | Report Type | Sample Command |
Normal | -oN | Human-readable report | Text | nmap -oN scan_report.txt <target_ip_address(es)>
Output File: scan_report.txt |
XML | -oX | Machine-readable, tool integration | XML | nmap -oX scan_report.xml <target_ip_address(es)>
Output File: scan_report.xml |
Grepable | -oG | CLI parsing and automation (legacy) | Text | nmap -oG scan_report.gnmap <target_ip_address(es)>
Output File: scan_report.gnmap |
JSON | - | Custom reporting, API integration | JSON (converted) | Using third party tools like xml2json and xmltodict |
All Formats | -oA | Comprehensive output | Multiple Types | nmap -oA scan_report <target_ip_address(es)>
Output Files: scan_report.txt scan_report.xml scan_report.gnmap |
Useful Nmap commands for Security Auditing
Purpose | Command | Example |
Basic Port Scan | nmap <target_ip_address> | nmap 192.168.1.1 |
Scan Multiple Targets | nmap <multiple target_ip_address> | nmap 192.168.1.1 192.168.1.2 192.168.1.3 |
Scan Entire Subnet | nmap <target_ip_address>/<subnet> | nmap 192.168.1.0/24 |
Aggressive Scan (OS, Services, Scripts) | nmap -A <target_ip_address> | nmap -A 192.168.1.1 |
Scan Specific Ports | nmap -p <port_1>,<port_2> <target_ip_address> | nmap -p 22,80,443 192.168.1.1 |
Service and Version Detection | nmap -sV <target_ip_address> | nmap -sV 192.168.1.1 |
OS Detection | nmap -O <target_ip_address> | nmap -O 192.168.1.1 |
Using Nmap Scripting Engine (NSE) | nmap --script=vuln <target_ip_address> | nmap --script=vuln 192.168.1.1 |
Popular NSE scripts for Security Auditing
Script Name | Purpose | Example Commands |
vulners | Detects vulnerabilities using the Vulners.com database (requires internet) | nmap -sV --script=vulners <target_ip> |
http-vuln-cve2006-3392 | Checks for PHP remote code execution vulnerability | nmap -p 80 --script=http-vuln-cve2006-3392 -v <target-ip> |
ssl-cert | Retrieves and analyzes SSL certificate information | nmap -p 443 --script=ssl-cert example.com |
http-methods | Lists HTTP methods supported by the server (e.g., PUT, DELETE) | nmap --script=http-methods -p 80,443 <target_ip> |
http-headers | Lists HTTP response headers to identify security misconfigurations | nmap --script= http-headers -p 80,443 <target_ip> |
smb-enum-shares | Enumerates SMB shares on a remote host | nmap -p 445 --script=smb-enum-shares <target-ip> |
ftp-anon | Checks for anonymous FTP login | nmap -p 21 --script=ftp-anon <target-ip> |
ssh-brute | Performs brute-force SSH login attempts (requires brute category) | nmap -p 22 --script ssh-brute <target_ip> |
dns-zone-transfer | Tests DNS servers for zone transfer vulnerabilities | nmap -p 53 --script=dns-zone-transfer --script-args=dns-zone-transfer.domain=example.com <DNS-IP> |
ssl-enum-ciphers | Checks SSL/TLS protocol versions and cipher suite strength | nmap --script ssl-enum-ciphers -p 443 <target_ip> |
vuln | Runs all vulnerability scripts | nmap --script=vuln <target_ip> |
Conclusion
Nmap remains one of the most powerful and versatile tools in the cybersecurity toolkit for conducting comprehensive security audits. Its ability to perform detailed port scanning, service enumeration, OS detection, and vulnerability assessment through an extensive scripting engine (NSE) makes it invaluable for identifying and analyzing potential risks within a network. Integrating Nmap into regular security assessment workflows enhances an organization’s ability to maintain a robust security posture, ensures compliance, and supports proactive threat management. Overall, Nmap plays a critical role in both offensive and defensive cybersecurity strategies, bridging the gap between discovery and actionable insight.
How Sujosu Can Help
We, at Sujosu Technology have deep expertise in cybersecurity and infrastructure assessment. We intend to help organizations strengthen their security posture by delivering actionable insights through detailed and responsible Nmap-driven audits. We bring technical expertise, ethical practices, actionable reporting, and scalable services suitable for businesses of all sizes. Get in touch with us for any service related to cybersecurity or any other queries.
Comments