From the course: Complete Guide to Penetration Testing

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Using Scapy to work with packets

Using Scapy to work with packets

- [Instructor] It's occasionally useful when testing to use raw packets to probe a target. We can do this in Python by invoking the Scapy library. Scapy is a Python tool, but it also comes as a library to use within our own Python scripts. It enables us to create each of the layers of a packet, and within those layers, to set all or any of the fields. Let's try a simple demonstration of Scapy to create a SYN flood, and we'll prepare a script called spack.py; nano spack.py. Okay, here we can see the flood routine setting a loop up across all target ports and create a TCP SYN packet with its source and destination IP addresses and source and destination ports, and sending it to all ports on the target. Okay, let's run this script against our Metasploitable server; sudo python spack.py. Okay, this is sending out a lot of packets. Of course, this isn't a sophisticated flood, but it does demonstrate the ease of using Scapy.

Contents