The first layer that we will need to construct is the IP layer: :~# scapy To send a UDP request to any given port, we first need to build layers of that request. The technique that we will use with Scapy is to identify closed UDP ports with ICMP port-unreachable replies. Knowledge of any particular service can make it easier to positively identify that service however, there are general techniques that can be used to determine, with a reasonable amount of accuracy, whether a service is running on a given UDP port. This can prove to be very difficult, as many UDP services will only reply to service-specific requests. To positively confirm the existence of a UDP service on any given port, we will need to solicit a reply from that service. Using Scapy, we can quickly develop an understanding of the underlying principles behind how UDP scanning works. Additionally, this section will require a script to be written to the filesystem using a text editor, such as VIM or Nano. In the examples provided, an instance of Metasploitable2 is used to perform this task. To use Scapy to perform UDP scanning, you will need to have a remote system that is running network services over UDP. This can be done by sending an empty UDP packet to destination ports and then identifying the ports that do not respond with an ICMP port-unreachable response. In this specific recipe, Scapy will be used to scan for active UDP services. Scapyis a tool that can be used to craft and inject custom packets into a network. Read an extract of the book UDP scanning with Scapy