nmap

Always check your privilages before writing a report. (ROOT)

Docs

Reference

  1. Site Unreachable

Insane speed, no DNS resolution and port specification

nmap -T5- -n -p1-65535 192.168.0.102

Insane speed, no host discovery, no DNS resolution and all ports

nmap -T5- -Pn -n -p- 192.168.0.102

No host discovery, Stealth Scan and specify ports

nmap -Pn -sS -p 1-65535 10.10.11.202

Script, Stealth Scan, Version Detection and verbose output

nmap -sCVS -vvv 10.10.11.202

Stealth Scan, Version Detection, no host discovery and no DNS resolution

nmap -sS -sV -Pn -n 192.168.60.130

Aggresive Scan, no host discovery and no DNS resolution

nmap -A -Pn -n 192.168.130.60

Version detection, no host discovery, vulnerability script and no DNS resolution

nmap -sV -Pn --script vuln -n 192.168.60.130
nmap -Pn -n -sV 10.10.159.242
nmap -Pn -n -T5 -p- 10.10.69.159

Scanning Subnets

nmap -sn 192.168.1.0/24
nmap 10.129.2.0/24 -sn -oA tnet | grep for | cut -d" " -f5 > hosts.lst

Hosts file

reason gives why the port is up

nmap -iL hosts.lst -sn -oA host -PE --reason

Trace Packets using nmap

nmap 10.129.2.28 -sU -Pn -n --disable-arp-ping --packet-trace -p 137 --reason

Host Discovery Techniques

  • ICMP Ping Scan (-PE, -PP, -PM): Nmap sends ICMP echo requests, timestamp requests, or netmask requests to determine if a host is online. If the target responds, it confirms the host is reachable.
  • TCP Ping Scan (-PS, -PA, -PU, -PY): Instead of ICMP, Nmap sends TCP SYN or ACK packets to specific ports. If the target replies (e.g., with a SYN-ACK), it indicates the host is active. This method is useful when ICMP is blocked by firewalls.
  • Ping Scan (-sn): This disables port scanning and only performs host discovery using the selected method (ICMP, TCP, or UDP).
  • ARP Scan (-PR): Instead of sending ICMP or TCP packets, Nmap sends ARP requests to determine if a host is online.

Ping

arp ping scan

On most LANs, especially those using private address ranges granted by RFC 1918

nmap -sn -PR 192.168.60.130

ICMP Ping Scan

Like -sn but only ICMP Echo requests are used

nmap -sn -PE 192.168.60.130

ICMP Timestamp Ping

nmap -sn -PP 192.168.60.130

ICMP Address mask Ping

ICMP Address Mask Ping Scan

nmap -sn -PM 10.10.1.13

TCP SYN Ping Scan

nmap -sn -PS 192.168.60.130

UDP Ping Scan

nmap -sn -PU 192.168.60.130

Scan top 10 ports

nmap 10.129.2.28 --top-ports=10

Traceroute

nmap -sn --traceroute 192.168.60.130

Slow Comprehensive Scan

Shodan is required

nmap -sS -sU -T4 -A -v -PE -PP -PS80,443 -PA3389 -PU40125 -PY -g 53 --script "default or (discovery and safe)" 192.168.60.129-130

Scanning Windows machine

  1. network - Nmap says host down when host is up - Information Security Stack Exchange

OS Detection

sudo nmap -O 192.168.64.5

UDP

nmap -sU -p- TARGETIP

UDP port scanning

nmap -sU -p 8080 TARGETIP

Server Message Block

nmap --script smb-os-discovery TARGET
nmap --script smb-enum-users TARGET

Saving to file

nmap -sV -Pn -F -n -oN scan1.txt 192.168.60.130

Default Options