Module 5 · Scanning and enumeration with Nmap · Lesson 15 of 16

Discovery, ports, versions, scripts and evidence

The Nmap flags you use on every engagement, which NSE scripts are safe, and how to save output as evidence.

In this lesson · about 20 minutes

  • Run host discovery before port scans
  • Choose between -sS, -p, -p-, -sV, -O and -T4
  • Run a safe NSE script and save output with -oA

Find the live hosts

Scanning thousands of ports on addresses that do not exist wastes time. Start with host discovery, which asks only "who is here?":

nmap -sn 192.168.56.0/24

-sn means "no port scan". On a local network Nmap uses ARP, which is fast and reliable. Every address it finds goes on your target list for the rest of the engagement.

Ports and services

With a target chosen, scan its ports, then ask what software answers on the interesting ones. Version numbers are what connect a port to a known vulnerability in Module 6.

FlagWhat it doesWhen to use it
-sSSYN (half-open) scanDefault choice when you have root.
-p 22,80Scan only these portsFollowing up on something specific.
-p-Scan all 65,535 TCP portsThorough pass; services hide on odd ports.
-sVProbe for service name and versionAlways, on ports you care about.
-OGuess the operating systemBuilding a picture of the host.
-T4Faster timingStable lab networks. Slow down for fragile client systems.

Scripts that ask questions

The Nmap Scripting Engine (NSE) ships with hundreds of small scripts that ask a service a specific question. ftp-anon, for example, checks whether an FTP server lets anyone log in without a password.

nmap --script ftp-anon -p 21 192.168.56.101

Save your evidence

A scan that only lived on your screen did not happen, as far as the report is concerned. -oA name saves three files at once: .nmap for people to read, .gnmap for grep, and .xml for other tools. Keep one folder per engagement and put the date in file names.

Guided dialogue

Pick the right scan

0 of 4 answered

C

Four quick situations from the Tana Roasters engagement. Choose the command a professional would run.

C

You have just been handed the subnet 192.168.56.0/24 and know nothing else.

For authorized, lab-based learning only. Tana Roasters and every person, address and password in this course are fictional. Every terminal is simulated. "Kali Linux" is a trademark of OffSec; this course is not affiliated with or endorsed by OffSec.