Load Nmap Scripting Engine
In this step, we'll explore the powerful Nmap Scripting Engine (NSE), which acts like a toolbox that extends Nmap's basic scanning capabilities. Think of NSE as adding specialized tools to your network scanner - it contains hundreds of pre-written scripts that can detect vulnerabilities, gather detailed service information, and perform advanced network discovery tasks.
Before we begin, it's important to understand that these scripts are already installed with Nmap on your system. Let's start by exploring what scripts are available:
-
First, we'll list all installed NSE scripts. This command shows you the complete collection of scripts in your Nmap installation:
ls /usr/share/nmap/scripts/
-
Each script has documentation explaining what it does. Let's examine the http-title script as an example - this script retrieves the title of web pages. The following command shows its purpose and usage:
nmap --script-help http-title
-
Now let's perform our first actual scan using NSE. This command scans your local machine (localhost) with two important options:
-sC
: Runs the default set of NSE scripts (safe and useful for most scans)
-sV
: Attempts to determine service versions (crucial for identifying outdated software)
nmap -sC -sV localhost
-
To target a specific script, we'll scan scanme.nmap.org (a test site provided by Nmap) using just the http-title script. This demonstrates how to focus on particular information:
nmap --script http-title scanme.nmap.org
-
Finally, you can combine multiple scripts for more comprehensive scanning. This example runs both the http-title and http-headers scripts against scanme.nmap.org:
nmap --script "http-title and http-headers" scanme.nmap.org
Remember that different scripts serve different purposes - some gather information while others test for vulnerabilities. Always check a script's documentation before using it on production systems.