python-3.xscapyigmp

Unable to compute checksum for igmpv3 using scapy


File : https://easyupload.io/w81oc1

from scapy.all import *
from scapy.utils import rdpcap
from scapy.utils import wrpcap
import scapy.contrib.igmpv3

#Read the pcap file    
pkt = rdpcap("test.pcap")


#Edit the value of qqic    
pkt[0]['IGMPv3mq'].qqic = 30

# Writ it to the pcap file.
#wrpcap("final.pcap",pkt)

PCAP


Solution

  • When you edit a packet (particularly an explicit packet, that is, a packet that has been read from a PCAP file or a network capture) in Scapy, you have to "delete" the fields that need to be computed again (checksum fields as here, but also sometimes length fields). For that, you can use the del statement:

    from scapy.all import *
    load_contrib("igmpv3")
    
    # Read the pcap file    
    pkt = rdpcap("test.pcap")
    
    # Edit the value of qqic    
    pkt[0]['IGMPv3mq'].qqic = 30
    
    # Force Scapy to compute the IGMP checksum
    # XXX the important line is here XXX
    del pkt[0][IGMPv3].chksum
    
    # Write it to the pcap file.
    wrpcap("final.pcap", pkt)
    

    I have also simplified the imports.