10. Nmap Advance Scans

Scan all 65535 ports
By default Nmap only scan top 1000 ports and uses TCP as default protocol for port scan.
To scan all the 65535 ports we can use the -p 0-65535 or -p- option.

928babb329b865bde4b5e303a2e5ba89.png


UDP Port Scan
Most services on the internet uses TCP but services like DNS,SNMP and DHCP uses UDP.
UDP scan is slower and difficult as compare to TCP.

2e7099871c59d618e9846f35c133474d.png

How UDP scans work?
A UDP packet is sent to every targeted port.For ports such as 53 and 161, a protocol-specific payload is sent to increase response rate, but for most ports the packet is empty unless the --data, --data-string, or --data-length options are specified.

535d4e920a9def0937b394451f251798.png

To speed up UDP scans:

Scanning Metasploitable 2:

To scan all the UDP ports also we can use the -sU option (root privileges needed).
To scan both TCP and UDP ports we can use -sS (SYN scan) and -sU (UDP scan) options.
Use -T4 or -T5 to imporve speed and -sV or -sUV for service detection with UDP scan.

572de39cf3189c4d146d5470593ab80f.png

4a263aaaa6942534bf93cd9b02c1867a.png

Scanning Top 10 UDP orts

9b450e3add921656ff5d0a86036ddb6d.png

'--top-ports [number]' option can be used to scan most common ports which are usually open.

False Positives

76865da62a33c52b68a7973c6b99f864.png

UDP scans may cause a lot of false positives. When a scanned UDP port is closed the system will respond with a ICMP port unreachable message. The absence of such packet indicates that the UDP port is open.
When a firewall is present on the target host which blocks the ICMP unreachable message than all UDP ports appear to be open.


All or Aggressive Scan
This scan is known as intense scan in zenmap. It's good to perform this scan first on a machine as it provides a lot of information.

Syntax:

For scanning all TCP ports

nmap -v -A -T4 -p- [TARGET]

9f19233e6751cec208b4ef50eaafab92.png

For Scanning top 1000 UDP ports

nmap -sU -v -A -T4 [TARGET]

Scans performed:

Note:

  1. Script scanning with the default set is intrusive.

  2. OS detection and traceroute requires root.