UnixDroid

Lesson 04 of 5

Nmap Scripting Engine (NSE): -sC, --script vuln and Useful Scripts

4 min read

Use NSE scripts to read web pages, SMB info and SSL settings, and to check for known vulnerabilities safely.

The Nmap Scripting Engine (NSE) is what makes Nmap much more than a port scanner. NSE scripts are small programs, written in the Lua language, that Nmap runs against the hosts and ports it finds. Kali ships with 600+ of them. They can grab web page titles, list SMB shares, grade SSL settings, test logins and check for known vulnerabilities.

Where are the NSE scripts stored?

On Kali Linux they live in /usr/share/nmap/scripts/:

ls /usr/share/nmap/scripts/ | wc -l
ls /usr/share/nmap/scripts/ | grep http

Read what a script does before you run it:

nmap --script-help http-title

NSE script categories

Nmap Scripting Engine NSE script categories grouped by risk: default, safe, vuln, brute, exploit
Nmap Scripting Engine NSE script categories grouped by risk: default, safe, vuln, brute, exploit

Every script belongs to one or more categories, and the category tells you how risky it is:

  • default – the set that -sC runs; picked because they're fast and useful
  • safe – won't crash services or eat lots of bandwidth
  • discovery – collects more information about the network and its services
  • version – helps -sV identify tricky services
  • vuln – checks for specific known vulnerabilities
  • auth – checks authentication, such as anonymous FTP login
  • broadcast – finds hosts by broadcasting on the local network
  • external – sends data to a third-party service, such as a CVE database
  • malware – checks whether a target looks infected or backdoored
  • intrusive – may crash something or look like an attack
  • brute – guesses passwords, and can lock out real user accounts
  • exploit – actively tries to exploit a vulnerability
  • dos – may cause a denial of service
  • fuzzer – sends random data to find bugs, and can crash services

Rule of thumb: default, safe, discovery and version are fine for learning. Run brute, exploit, dos, fuzzer or intrusive scripts only with written permission.

Run the default scripts with -sC

nmap -sC -sV 192.168.56.101

-sC is the same as --script=default. Together with -sV, it's the most common Nmap command you'll see in CTF write-ups.

Run one script, a category or a pattern

nmap --script http-title -p 80,443 192.168.56.101
nmap --script vuln -p 80,443 192.168.56.101
nmap --script "http-*" -p 80 192.168.56.101
nmap --script "default and safe" 192.168.56.101
nmap --script "not intrusive" 192.168.56.101

8 NSE scripts worth knowing

  • http-title – shows the page title of every web server it finds
  • http-enum – looks for common folders like /admin, /login and /backup
  • http-headers – prints server headers, where versions often leak
  • ssl-enum-ciphers – lists TLS versions and ciphers and grades them A to F
  • smb-os-discovery – pulls the OS, computer name and domain from Windows SMB
  • smb-enum-shares – lists shared folders on Windows and Samba
  • ftp-anon – checks whether FTP allows anonymous login
  • vulners – matches -sV versions against a CVE database (needs internet)

Example – grade the TLS setup of your own website:

nmap --script ssl-enum-ciphers -p 443 yourdomain.com

Script arguments

Some scripts take options through --script-args:

nmap --script http-enum --script-args http-enum.basepath=/app/ -p 80 192.168.56.101

If you add your own .nse files, refresh the script database:

sudo nmap --script-updatedb

Simple words mein (Hinglish)

NSE Nmap ke andar chhote-chhote Lua scripts hain jo extra kaam karte hain: website ka title nikalna, SMB shares dekhna, SSL check karna, vulnerabilities dhundhna. -sC se default scripts chalti hain aur --script vuln se vulnerability checks. Lekin brute, exploit, dos jaisi categories sirf likhi hui permission ke saath chalao, warna service crash ho sakti hai ya users ke accounts lock ho sakte hain.

FAQ

What does -sC mean in Nmap? It runs the default NSE scripts. It's the same as --script=default.

Can Nmap find vulnerabilities? Yes, with --script vuln or the vulners script. But it isn't a full vulnerability scanner like Nessus or OpenVAS, so always confirm findings by hand.

What language are NSE scripts written in? Lua.

Where are Nmap scripts stored in Kali Linux? In /usr/share/nmap/scripts/.

Practice task

  • Run nmap --script-help on three scripts from the list above
  • In your lab, run nmap -sC -sV against Metasploitable 2 and note every interesting finding
  • Run nmap --script vuln on the same target and compare it with your -sV results

Next lesson: advanced Nmap – faster scans, firewall testing, saving output and a complete recon workflow.