Activating a script from the Nmap Scripting Engine (NSE) involves using the Nmap command-line tool with specific options to select and run the desired script(s). Here’s a step-by-step guide on how to do it:
Prerequisites:
- Nmap Installation: Ensure Nmap is installed on your system. You can download it from https://nmap.org/download.html if it's not already installed.
- Understanding Script Names: Familiarize yourself with the name of the script you wish to activate. You can find a list of scripts in the Nmap directory (
/usr/share/nmap/scripts/ on many Linux systems) or by browsing the Nmap Script Catalog.
Basic Syntax to Activate a Script:
nmap -p <port(s)> --script <script_name> <target_IP/domain>
-p <port(s)>: Specifies the port(s) to scan. Many scripts require a specific port to be open to function properly. You can specify a single port (e.g., -p 80), a range (e.g., -p 1-100), or multiple ports (e.g., -p 22,80,443).
--script <script_name>: This option is used to specify the NSE script you want to activate. Replace <script_name> with the actual name of the script (e.g., http-title).
<target_IP/domain>: The IP address or domain name of the target you want to scan.
Examples:
1. Running a Single Script:
To run the http-title script against a target website (example.com) on port 80:
nmap -p 80 --script http-title example.com
2. Running Multiple Scripts:
You can specify more than one script by separating them with commas:
nmap -p 80 --script http-title,http-headers example.com
3. Running All Scripts in a Category:
Nmap allows you to run all scripts within a specified category. For example, to run all vuln (vulnerability) scripts on a target:
nmap --script "vuln and default" <target_IP/domain>
Note: The "vuln and default" part specifies that you want to run scripts categorized under vuln that are also marked as default (meaning they are typically run when the --script=default option is used without specifying a category).
4. Running All Default Scripts:
To run all default scripts (a curated set of generally useful scripts) against a target on all common ports:
nmap --script=default <target_IP/domain>
Additional Tips:
Always ensure you have the right to scan your target, as unauthorized scanning can be considered illegal in many jurisdictions.