UDP Scan Using Nmap
UDP Scan Using Nmap
In this lab, you will use the nmap -sU option to perform a UDP scan.
With this scan type, nmap sends 0-byte UDP packets to each port on the target system. Receipt of an
ICMPv4 Destination Unreachable/Port Unreachable (Type 3, Code 3) message signifies the port is closed;
otherwise it is assumed open.
One major problem with this technique is that when a firewall blocks outgoing ICMPv4 Type 3, Code 3
messages, the port will appear open. These false-positives are hard to distinguish from real open ports.
Another disadvantage with UDP scanning is the speed at which it can be performed. Most OSes limit the
number of ICMPv4 Type 3, Code 3 messages which can be generated in a certain time period, thus
slowing the speed of a UDP scan. nmap adjusts its scan speed accordingly to avoid flooding a network
with useless packets.
NOTE: Microsoft OSes do not limit the ICMPv4 Type 3, Code 3 error generation frequency, thus, making
it is easier to scan a Windows machine's 65,535 UDP ports in very little time.
Exercise 1:
1. From a BackTrack shell, type the following (only type what's in bold):
Syntax breakdown:
> /root/ceh/udpscan: redirect the output to a file called udpscan in the /root/ceh directory
4. Repeat steps #1-2 using different target IP addresses. Compare your results.
1.From a BackTrack shell, type the following (only type what's in bold):
Syntax breakdown:
> /root/ceh/connect_scan: redirect the output to a file called connect_scan in the /root/ceh
directory
In the next example, you will add two additional options: the -g and the –p options:
The -g option specifies the source port on the scanning machine (your system).
The most common option to use here is port 80 (because it's allowed through most
border network devices). The -p option sets the ports on the target system to scan.
1. Using the -sS flag option, you will send the target system a SYN packet, but upon
receiving the SYN/ACK from the target system, your system will not respond with an
ACK packet (thus, completing the 3-way handshake). Instead, your system will
respond with a RST packet (the port is then considered open). If you receive an
RST/ACK packet from the target system, it indicates that there is not a running
process on that port, or the process running on the port is not listening for
connections.
2. The syntax to perform a TCP SYN scan is (only type what's in bold, on one line):
Syntax breakdown:
-g 80: program option that specifies the source port on the scanning machine
(your system)
> /root/ceh/syn_scan: redirect the output to a file called syn_scan in the /root/ceh
directory
5. Repeat steps #2-3 using a different target IP address and different destination port
numbers
In this lab, you will use hping to perform a few basic port scans.
Syntax breakdown:
> /root/ceh/hping_out: redirect the output to a file called hping_out located in the
/root/ceh directory
2. After the scan runs for approximately 5 seconds, hit Ctrl+C to stop it
1. In this exercise, you will scan all well-known ports and redirect the output to a file called
hping_out1 in the /tmp directory. The resulting file will list the response (if any) from all
well-known ports. Notice the -V option in the following syntax (only type what’s in bold,
on one line):
Syntax breakdown:
Exercise 3: TCP SYN scan (range of addresses) viewing response from open ports:
1. In this exercise, you will scan all well-known ports again, and redirect the output to a file
called hping_out2 in the /tmp directory. In addition, you will eliminate the
-V option, which will show results only for open ports (only type what’s in bold, on one
line):
Syntax breakdown:
> /root/ceh/hping_out2: redirect the output to a file called hping_out2 located in the
/root/ceh directory
4. Compare this with the output in Exercise #2, #3. Are they the same? Should they be?
Why or why not.
Decoy Scan Using nmap
Exercise 1: in this exercise, you’ll use nmap to perform a decoy scan, which mixes
1. From a BackTrack shell, type the following (only type what's in bold, on one line):
user1@pentest:~#nmap -n -D192.168.1.5,10.5.1.2,me,172.1.2.4
target_IP_address > /root/ceh/decoy_scan
Syntax breakdown:
> /root/ceh/decoy_scan: redirect the output to a file called decoy_scan in the /root/ceh
directory