0
votes

I'm new to using scapy and I want to create a little program that sents packets that start with a size of 2 Byte and each next packet increases it's size by 2 byte.

I know that i can define a payload variable and put it as a parameter, but how can I create a payload that starts with exactly 2 bytes and how can I increase this?

1

1 Answers

0
votes

Using the / operator you can easily encapsulate any number of bytes you want in your packet. For instance, here I send 10 ICMP requests to 192.168.1.254 and increase the payload by two bytes at each step:

from scapy.all import IP, ICMP, send

payload = '  '
for i in range(10):
    p = IP(dst="192.168.1.254")/ICMP()/payload
    payload += '  '
    send(p)