10 NMAP Examples

12 Jun

Using NMAP for a current project, I wanted to identity more than just basic scan techniques. Here are 10 examples of NMAP in action :

Get info about remote host ports and OS detection
nmap -sS -P0 -sV -O

Where < target > may be a single IP, a hostname or a subnet

-sS TCP SYN scanning (also known as half-open, or stealth scanning)

-P0 option allows you to switch off ICMP Pings

-sV option enables version detection

-O flag attempt to identify the remote operating system

Other options:

-A option enables both OS fingerprinting and version detection

-v use -v twice for more verbosity.
nmap -sS -P0 -A -v < target >

Get list of servers with a specific port open

nmap -sT -p 80 -oG – 192.168.1.* | grep open

Change the -p argument for the port number. See “man nmap” for different ways to specify address ranges.

Find all active IP addresses in a network
nmap -sP 192.168.0.*

There are several other options. This one is plain and simple.

Another option is:

nmap -sP

for specific subnets.

Ping a range of IP addresses
nmap -sP

nmap accepts a wide variety of addressing notation, multiple targets/ranges, etc.

Find unused IPs on a given subnet
nmap -T4 -sP && egrep “00:00:00:00:00:00″ /proc/net/arp

Very useful when you require a free ip on a target network.

Scan for the Conficker virus on your LAN ect.
nmap -PN -T4 -p139,445 -n -v –script=smb-check-vulns –script-args safe=1

replace with the IP’s you want to check. The –script= option is very useful if you start to toy with the multitude of NMAP vulnerability scripts out there.

Scan Network for Rogue APs.
nmap -A -p1-85,113,443,8080-8100 -T4 –min-hostgroup 50 –max-rtt-timeout 2000 –initial-rtt-timeout 300 –max-retries 3 –host-timeout 20m –max-scan-delay 1000 -oA wapscan

I’ve used this scan to successfully find many rogue APs on a very, very large network.

Use a decoy while scanning ports to avoid getting caught by the sys admin
sudo nmap -sS -D

Scan for open ports on the target device/computer ( while setting up a decoy address ( This will show the decoy ip address instead of your ip in targets security logs. Decoy address needs to be alive. Check the targets security log at /var/log/secure to make sure it worked.

List of reverse DNS records for a subnet
nmap -R -sL | awk ‘{if($3==”not”)print”(“$2″) no PTR”;else print$3″ is “$2}’ | grep ‘(‘

This command uses nmap to perform reverse DNS lookups on a subnet. It produces a list of IP addresses with the corresponding PTR record for a given subnet. You can enter the subnet in CDIR notation (i.e. /24 for a Class C)). You could add “–dns-servers x.x.x.x” after the “-sL” if you need the lookups to be performed on a specific DNS server. On some installations nmap needs sudo I believe. Also I hope awk is standard on most distros.

How Many Linux And Windows Devices Are On Your Network?
sudo nmap -F -O | grep “Running: ” > /tmp/os; echo “$(cat /tmp/os | grep Linux | wc -l) Linux device(s)”; echo “$(cat /tmp/os | grep Windows | wc -l) Window(s) devices”

Hope you have fun, and remember don’t practice these techniques on machines or networks that are not yours.


One Response to “10 NMAP Examples”


  1. Today's Linux Server LinksNine OM - June 12, 2012

    […] 10 NMAP Examples Using NMAP for a current project, I wanted to identity more than just basic scan techniques. Here are 10 examples of NMAP in action : Get info about remote […] […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: