Mastering Nmap Scripts | A Complete Guide to Network Security Scanning and Vulnerability Detection
Nmap (Network Mapper) is a powerful tool used by cybersecurity professionals for network scanning, vulnerability detection, and security auditing. One of its most valuable features is the Nmap Scripting Engine (NSE), which allows users to automate various security tasks. NSE scripts help in detecting vulnerabilities, gathering system information, performing brute-force attacks, and identifying misconfigurations. This blog explores the most important Nmap scripts, their commands, real-world applications, and practical use cases. We will also discuss how to run these scripts effectively, ensuring a comprehensive network security assessment. Whether you are a penetration tester, system administrator, or ethical hacker, understanding Nmap scripts will significantly enhance your network security auditing skills.

Table of Contents
- Introduction
- How Nmap Scripting Works
- Categories of Nmap Scripts
- Most Important Nmap Scripts and Their Uses
- Real-Time Examples and Scenarios
- Conclusion
- FAQs
Introduction
Nmap (Network Mapper) is one of the most widely used network scanning tools by ethical hackers and cybersecurity professionals. While Nmap is primarily used for port scanning and network discovery, its true power lies in Nmap Scripting Engine (NSE). NSE allows users to automate various network reconnaissance and vulnerability detection tasks using scripts written in Lua programming language.
NSE scripts can perform various tasks, such as:
-
Detecting vulnerabilities
-
Gathering service information
-
Brute-forcing authentication
-
Exploiting known security flaws
-
Automating penetration testing tasks
These scripts make Nmap a powerful and flexible tool for ethical hacking and security auditing.
How Nmap Scripting Works
Nmap scripts are categorized into different groups based on their function. Users can specify which scripts to run based on their needs.
To run a specific Nmap script, the following command is used:
nmap --script
To run multiple scripts:
nmap --script ,
To run all scripts in a category:
nmap --script
To get more information about a script:
nmap --script-help
Categories of Nmap Scripts
Nmap scripts are divided into the following categories:
Category | Description |
---|---|
Auth | Used for authentication bypass and brute-force attacks |
Broadcast | Discovers hosts on a network |
Brute | Performs brute-force attacks on authentication systems |
Discovery | Identifies services, users, and network information |
Dos | Conducts Denial-of-Service (DoS) attacks |
Exploit | Exploits known vulnerabilities |
External | Uses external services for additional information |
Fuzzer | Sends unexpected inputs to test vulnerabilities |
Intrusive | Performs aggressive security scans |
Malware | Detects malware-infected systems |
Safe | Conducts non-intrusive information gathering |
Version | Detects version details of services |
Vuln | Identifies vulnerabilities on a target |
Most Important Nmap Scripts and Their Uses
Below is a list of important Nmap scripts, along with their commands and real-time examples:
Script Name | Use Case | Command Example | Real-World Scenario |
---|---|---|---|
http-title | Retrieves the title of a webpage | nmap --script=http-title |
Used to identify a website’s default page |
http-enum | Enumerates directories and files on a web server | nmap --script=http-enum |
Helps in finding hidden files and directories |
smb-os-discovery | Detects the OS version of a Windows system | nmap --script=smb-os-discovery |
Used in penetration testing to gather Windows version information |
smb-vuln-ms17-010 | Checks if a target is vulnerable to EternalBlue (MS17-010) | nmap --script=smb-vuln-ms17-010 |
Used for checking WannaCry ransomware vulnerabilities |
ftp-anon | Checks for anonymous FTP login access | nmap --script=ftp-anon |
Helps in detecting unsecured FTP servers |
ssh-brute | Performs brute-force attacks on SSH | nmap --script=ssh-brute |
Used to test weak SSH passwords |
dns-brute | Performs brute-force subdomain enumeration | nmap --script=dns-brute |
Used in reconnaissance to find hidden subdomains |
ssl-heartbleed | Checks for Heartbleed vulnerability | nmap --script=ssl-heartbleed |
Identifies vulnerable SSL/TLS implementations |
mysql-brute | Performs brute-force attack on MySQL | nmap --script=mysql-brute |
Used to check for weak MySQL passwords |
http-robots.txt | Checks for sensitive information in robots.txt |
nmap --script=http-robots.txt |
Helps in finding restricted website paths |
smb-brute | Brute-forces SMB login credentials | nmap --script=smb-brute |
Tests for weak Windows SMB authentication |
rdp-enum-encryption | Checks RDP encryption settings | nmap --script=rdp-enum-encryption |
Used to assess the security of Remote Desktop Protocol |
snmp-brute | Attempts to guess SNMP community strings | nmap --script=snmp-brute |
Helps in identifying misconfigured SNMP services |
smtp-enum-users | Enumerates email users on an SMTP server | nmap --script=smtp-enum-users |
Helps in gathering user lists for phishing attacks |
http-slowloris | Tests if a web server is vulnerable to Slowloris DoS attack | nmap --script=http-slowloris |
Used in stress testing of web servers |
Real-Time Examples and Scenarios
1. Detecting Vulnerable Windows Machines
A security team at a company wants to check if any Windows servers are vulnerable to EternalBlue (MS17-010), a flaw used by the WannaCry ransomware.
Command:
nmap --script=smb-vuln-ms17-010 -p 445 192.168.1.100
Expected Output:
-
If vulnerable: The system is affected by MS17-010
-
If not vulnerable: No vulnerabilities detected
2. Checking for Anonymous FTP Access
A hacker wants to check if an FTP server allows anonymous access, which can lead to data leaks.
Command:
nmap --script=ftp-anon -p 21
Scenario:
If the scan confirms anonymous access, an attacker can download sensitive files without credentials.
3. Brute-Forcing SSH Credentials
A penetration tester needs to test if an SSH server has weak passwords.
Command:
nmap --script=ssh-brute -p 22
Scenario:
If a weak password is found, attackers may gain unauthorized SSH access to the system.
4. Enumerating Hidden Web Pages
A security researcher is analyzing a website for hidden files and directories.
Command:
nmap --script=http-enum -p 80
Scenario:
The scan may reveal admin panels, backup files, and sensitive information that attackers could exploit.
Conclusion
The Nmap Scripting Engine (NSE) is a powerful tool for ethical hackers, penetration testers, and security researchers. It allows for automated vulnerability scanning, reconnaissance, and exploitation with just a few simple commands.
By mastering Nmap scripts, cybersecurity professionals can detect vulnerabilities, identify misconfigurations, and strengthen network security before attackers can exploit them.
FAQs
What is Nmap?
Nmap (Network Mapper) is a free and open-source tool used for network discovery, security scanning, and vulnerability assessment.
What is the Nmap Scripting Engine (NSE)?
NSE is a scripting framework within Nmap that allows users to automate network security tasks using Lua-based scripts.
How do I run an Nmap script?
Use the following command:
What are the main categories of Nmap scripts?
Nmap scripts are categorized into Auth, Brute, Discovery, Exploit, Safe, Intrusive, Malware, Version, Vuln, and more.
What is the purpose of Nmap auth scripts?
Auth scripts check for authentication bypass vulnerabilities and test weak login credentials.
How do I list all available Nmap scripts?
Use this command:
Can I run multiple Nmap scripts at once?
Yes, use:
How do I run all scripts in a specific category?
Use:
Example:
What is the smb-vuln-ms17-010 script used for?
It checks if a system is vulnerable to EternalBlue (MS17-010), which was used in the WannaCry ransomware attack.
How do I check for anonymous FTP access using Nmap?
Use:
What is the http-enum script used for?
It enumerates directories and files on a web server to find hidden content.
How do I check for weak SSH credentials?
Run:
What is the dns-brute script used for?
It performs brute-force DNS enumeration to find subdomains of a target website.
How do I detect if a system is vulnerable to Heartbleed?
Use:
What is the smb-os-discovery script used for?
It detects the Windows OS version running on a target system.
How do I check for hidden admin panels using Nmap?
Use:
What does the http-robots.txt script do?
It extracts disallowed paths from a website's robots.txt
file.
Can Nmap be used for brute-force attacks?
Yes, scripts like ssh-brute, smb-brute, and mysql-brute are used for brute-force attacks.
How do I check for misconfigured SNMP services?
Run:
What is the smb-brute script used for?
It performs brute-force attacks on Windows SMB authentication.
How do I test if an RDP server is properly encrypted?
Use:
What is the smtp-enum-users script used for?
It enumerates email users on an SMTP mail server.
How do I test if a web server is vulnerable to a Slowloris DoS attack?
Run:
How do I check if an SSL/TLS certificate is valid?
Use:
Can Nmap detect malware-infected hosts?
Yes, Nmap has malware detection scripts that analyze suspicious network behavior.
How do I find live hosts on a network using Nmap?
Use:
What is the broadcast category in Nmap scripts?
Broadcast scripts are used to discover hosts on a local network using multicast/broadcast protocols.
How do I check for open ports using Nmap?
Run:
How do I create my own Nmap script?
You can write custom Nmap scripts using Lua programming language and place them in the scripts/
directory.
How do I update my Nmap scripts?
Use the following command to update the script database: