Connect scanning with Scapy
With most scanning tools, TCP connect scanning is an easier process than SYN scanning. This is because TCP connect scanning does not require the elevated privileges that are needed to generate and inject the raw packets used in SYN scanning. Scapy is the one major exception to this. It is actually very difficult and impractical to perform a full, TCP three-way handshake with Scapy. However, for the sake of understanding the process better, we will see how to use Scapy to perform a connect scan in this recipe.
Getting ready
To use Scapy to perform a full connect scan, you will need to have a remote system that is running network services over TCP. In the examples provided, an instance of Metasploitable2 is used to perform this task. For more information on how to set up Metasploitable2, refer to Chapter 1, Getting Started. Additionally, this section will require a script to be written to the filesystem using a text editor, such as VIM or Nano. For more information...