I often find myself explaining to people how to install a script that isn’t included in Nmap. Rather than write it over and over, this is a quick tutorial.
Step 1: Figure out where your scripts are stored
First, you have to find out where your scripts are installed. The easiest way to do that is to search your harddrive for *.nse files.
Windows Key + F, *.nse
find / -name '*.nse' locate *.nse
The common places are:
c:\Program Files\Nmap\Scripts /usr/share/nmap/scripts /usr/local/share/nmap/scripts
While you’re at it, in the same folder as ‘scripts’, there should be another folder called ‘nselib’, which contains files named *.lua. That’s where libraries go.
Step 2: Get the script + libraries
Usually, I’ll provide you with a link to the .nse file. All you have to do is download it and copy it into one of the directories above. If there are libraries to go with it (.lua files), copy them into the nselib folder.
Alternatively, you might be able to download them from the Nmap site itself, typically in the scripts folder.
Step 3: Update script database (optional)
If you want to run the script using a wildcard or category, you have to run Nmap’s script update command: $ nmap –script-updatedb
Note: if you’re ok with giving the full name of the script, this isn’t necessary.
Step 4: Run it!
The last step is to run the script. Whether you are on the commandline or using Zenmap, the argument is the same: –script <scriptname>
So basically, you find the path where the scripts are stored, copy the script there, and run it. Simple!
Now I can link back to this post whenever I write a new script. :)