Common attacks

In this example, let's look at how we can construct our packet to conduct some of the classic attacks, such as Ping of Death (https://en.wikipedia.org/wiki/Ping_of_death) and Land Attack (https://en.wikipedia.org/wiki/Denial-of-service_attack). This is perhaps the network penetration tests that you previously had to pay for with a similar commercial software. With Scapy, you can conduct the test while maintaining full control as well as adding more tests in the future.

The first attack basically sends the destination host with a bogus IP header, such as the length of 2 and the IP version 3:

def malformed_packet_attack(host):    send(IP(dst=host, ihl=2, version=3)/ICMP()) 

The ping_of_death_attack consists of the regular ICMP packet ...

Get Mastering Python Networking - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.