Nmapcommands
Nmapcommands
Scan Techniques
Switch Example Description
Host Discovery
Switch Example Description
-sn nmap 192.168.1.1/24 -sn Disable port scanning. Host discovery only.
-Pn nmap 192.168.1.1-5 -Pn Disable host discovery. Port scan only.
Switch Example Description
Port Specification
Switch Example Description
-p nmap 192.168.1.1 -p U:53,T:21-25,80 Port scan multiple TCP and UDP ports
--top-ports nmap 192.168.1.1 --top-ports 2000 Port scan the top x ports
-sV --version- nmap 192.168.1.1 -sV -- Enable light mode. Lower possibility of
light version-light correctness. Faster
-sV --version-all nmap 192.168.1.1 -sV -- Enable intensity level 9. Higher possibility of
version-all correctness. Slower
OS Detection
Switch Example Description
5h
NSE Scripts
Switch Example Description
Example
http and
banner
Command Description
nmap -n -Pn -p 80 --open -sV -vvv --script banner,http-title -iR Fast search for random web
1000 servers
nmap -n -Pn -vv -O -sV --script smb-enum*,smb-ls,smb- Safe SMB scripts to run
mbenum,smb-os-discovery,smb-s*,smb-vuln*,smbv2* -vv
192.168.1.1
--data- nmap --data-length 200 192.168.1.1 Appends random data to sent packets
length
Example IDS Evasion command
Output
Switch Example Description
--packet-trace nmap 192.168.1.1 -T4 --packet-trace Show all packets sent and
received
Command Description
nmap -p80 -sV -oG - --open 192.168.1.1/24 | Scan for web servers and grep to show which
grep open IPs are running web servers
nmap -iR 10 -n -oX out.xml | grep "Nmap" | cut Generate a list of the IPs of live hosts
-d " " -f5 > live-hosts.txt
nmap -iR 10 -n -oX out2.xml | grep "Nmap" | Append IP to the list of live hosts
cut -d " " -f5 >> live-hosts.txt
ndiff scanl.xml scan2.xml Compare output from nmap using the ndif
grep " open " results.nmap | sed -r 's/ +/ /g' | sort Reverse sorted list of how often ports turn up
| uniq -c | sort -rn | less
Miscellaneous Options
Switch Example Description
nmap 192.168.1.1-1/24 -PR -sn -vv Arp discovery only on local network, no port
scan
nmap 192.168.1.1-50 -sL --dns-server Query the Internal DNS for hosts, list targets
192.168.1.1 only
-Pn The
-Pn flag prevents host discovery pings and just
assumes the host is up. In this case, I know the host is up
because i’m hosting it locally.
-sS The -sS flag is for a SYN scan.
-T5 The next flag, -T5, tells nmap to scan REALLY fast.
The last flag, -oA, tells nmap to output all formats and
-oA
name them “nmap_basic_all” with the proper extension