Nmap from Scratch | Part-6 | NSE ( Nmap Scripting Engine )

Initially, Nmap was just a port scanner, but on 10th December 2006, Nmap launched the NSE (Nmap scripting engine) which changed the entire thing about how people looked at Nmap, now it was not just a port scanner but a port scanner with so much more.

Nmap contains a total number of 589 scripts (Version 7.70), there are a lot of scripts that are useful but not all of them works perfectly, it’s like other tools a better for that particular task, so we’ll look at how we can use the powerful NSE and what scripts to use.

To see all the scripts, navigate to

/usr/share/nmap/scripts

According to Nmap manual

-sC performs a script scan using the default set of scripts. It is equivalent to --script=default. Some of the scripts in this category are considered intrusive and should not be run against a target network without permission.

So, kindly take permission before running this type of scan against a target .

SYNTAX:

nmap -sC nmap.scanme.org

For manually specifying script we use

Using this option we specify a script, and use other options like help to understand what the script is used for.

The best way to find out a script according to your need is to use the locate command, so let’s suppose if we want to search for all SSH scripts, we’ll write

locate *ssh*.nse

Result:

We can see that we have total seven script for SSH, to understand what does a script do, we can write:

SYNTAX:

nmap --script-help script_name.nse

Example:

nmap --script-help ssh-brute.nse

Result:

So let’s see it in action

Scanning the target for SSH

nmap -sS nmap.scanme.org -p 22

Result:

From the result we can conclude that port 22 is open, now let’s find what version of SSH the target host is running.

nmap -sS -sV nmap.scanme.org -p 22

Result:

So the target system is running OpenSSH 6.6.1p1 we can look out for exploits for this version of SSH on the internet, but for now we’ll only use the script.

Brute forcing SSH login using NSE:

nmap  --script ssh-brute.nse nmap.scanme.org -vv -p 22

Nmap will try every possible username-password combination present in it’s word list to brute force the target.

In brief:

  • Scan the target and find out the services running
  • Look for exploits for the running service on the internet.
  • Try to exploit the target ( using any tool from plethora of different tools )
  • If the exploit fails, try another exploit
  • If it fails again , try again, until you successfully exploit the target.

Remember:

“The master has failed more times than the beginner has even tried.”

STEPHEN MCCRANIE

Few more script:

--script banner           #grab banner
--script broadcast #reveals broadcast information
--script vuln #will use default scripts to report vulnerabilities if any.##Looking for specific scripts#Basic syntax:
locate *service name*.nse
examples:
locate *smb*.nse #will list all SMB related scripts
locate *http*.nse #list all web related scripts

That’s it for this blog, try to play around the NSE scripts, you can even install new scripts from the internet using wget and don’t forget to update the NSE engine using

nmap --script-updatedb

In next blog we’ll cover how to work upon the timing and performance of Nmap scans, till then keep practicing !

--

--

--

Infosec Enthusiast | Student

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

WolfSafePoorPeople’s Latest RoadMap Update

{UPDATE} iMusicInstruments Hack Free Resources Generator

Listing Ardor Token (ARDR) on VNDC Wallet

featured_image

Responsible Web Scraping: Gathering Data Ethically and Legally

{UPDATE} Fairy Salon Hack Free Resources Generator

The Twitter Hack — Explained

GDPR: A brief overview for data security

Speaker talks at the Internet Health Hackathon

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
A3h1nt

A3h1nt

Infosec Enthusiast | Student

More from Medium

Vulnerability Scanning with Metasploit

Let’s Become a Cloud Security Engineer #3: Exploit Vulnerabilities(THM)

Hacking? Hacker? What?

CEH or eJPT? After 12th!