Nmap Scripting Engine Guide: Categories, Safe Scripts and Usage
The Nmap Scripting Engine (NSE) lets Nmap run Lua scripts that collect extra information about hosts and services, such as TLS details, HTTP titles or SMB settings, and check for some known vulnerabilities. Scripts are grouped into categories like default, safe, discovery, version, vuln and intrusive.
Topic: Security Tools, Authorized Labs & CTFs in Cybersecurity & Ethical Hacking · Tutorial
Also covers: Network Security, Ethical Hacking, Cyber Threats, Scams & Online Safety
Quick answer: The Nmap Scripting Engine (NSE) lets Nmap run Lua scripts that collect extra information about hosts and services, such as TLS details, HTTP titles or SMB settings, and check for some known vulnerabilities. Scripts are grouped into categories like default, safe, discovery, version, vuln and intrusive. Run nmap -sC for the default set, --script safe for low-risk checks, and read --script-help before using any script you do not know. Intrusive, brute and dos scripts can lock accounts or crash services. Run NSE only against systems you own or have written permission to scan.
Key takeaways
- NSE extends Nmap with Lua scripts grouped into categories.
- -sC runs the default category, which Nmap designs to be reasonably safe.
- Check --script-help before running unfamiliar scripts.
- Intrusive categories need explicit approval in your rules of engagement.
- Scanning without permission can be an offence in India.
Table of Contents
- What Is the Nmap Scripting Engine?
- What Are the NSE Script Categories?
- How Do You Tell Safe Scripts From Intrusive Ones?
- How Do You Run Scripts on an Authorised Target?
- How Do Script Arguments and Output Work?
- How Do Defenders Use and Detect NSE?
- What Rules Apply Before Scanning?
- References
What Is the Nmap Scripting Engine?
NSE is built into Nmap and runs scripts written in Lua during or after a scan. The Nmap book chapter on NSE lists its main uses: network discovery, better version detection, vulnerability detection and backdoor detection. Every script is documented in the NSEDoc portal. For Nmap basics, see understanding Nmap for vulnerability scanning.
What Are the NSE Script Categories?
| Category | Purpose | Risk level |
|---|---|---|
| default | Run by -sC; useful and fast | Low |
| safe | Not designed to crash services or be intrusive | Low |
| discovery | Learn more about the network and services | Low to medium |
| version | Extends -sV version detection | Low |
| broadcast | Discover hosts by broadcasting on the local network | Low to medium |
| external | Sends data to third-party services | Privacy concern |
| vuln | Check for specific known vulnerabilities | Medium |
| auth | Deal with authentication settings | Medium |
| intrusive | May crash services or use many resources | High |
| brute | Guess credentials | High, lockouts |
| dos | May cause denial of service | High |
| exploit | Try to exploit a vulnerability | High |
| fuzzer | Send unexpected input | High |
| malware | Detect signs of infection or backdoors | Low to medium |
These 14 categories are defined in the NSE usage documentation. A script can belong to several.
How Do You Tell Safe Scripts From Intrusive Ones?
Read the script's help before running it:
nmap --script-help ssl-cert
nmap --script-help "safe and discovery"
sudo nmap --script-updatedb
The help output lists categories and a description. The external category matters for privacy, because those scripts send target data to outside services, which may breach client confidentiality.
How Do You Run Scripts on an Authorised Target?
Examples against a lab host you own (192.168.56.10):
nmap -sV -sC 192.168.56.10
nmap -p 443 --script ssl-cert,ssl-enum-ciphers 192.168.56.10
nmap -p 80,443 --script http-title,http-headers 192.168.56.10
nmap --script "safe and not external" 192.168.56.10
Boolean expressions with and, or and not are supported, as described in the NSE reference guide. Use them to exclude risky categories explicitly.
How Do Script Arguments and Output Work?
| Option | Use |
|---|---|
| --script-args | Pass settings, such as http.useragent |
| --script-trace | Show script traffic for debugging |
| -oA name | Save normal, XML and grepable output for the report |
| --script-timeout | Stop slow scripts |
Save output with -oA so findings can be verified and repeated after fixes. Release notes such as Nmap 7.96 list new and updated scripts.
How Do Defenders Use and Detect NSE?
Blue teams use safe scripts to audit their own estate: expired certificates, weak TLS ciphers, missing security headers and exposed SMB settings. To detect unwanted scanning, watch IDS alerts for NSE default HTTP user agents and many connections across ports from one source. Store these logs; CERT-In directions require 180-day log retention for many organisations in India.
What Rules Apply Before Scanning?
The Nmap legal issues chapter advises getting permission before scanning networks you do not control. Plan tests under NIST SP 800-115 and remember that unauthorised access attempts can fall under Sections 43 and 66 of the IT Act 2000. WebAsha teaches Nmap in supervised labs within its ethical hacking training.
References
Frequently Asked Questions
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Wow
0
Sad
0
Angry
0