开发者

Comparing TCP checksums with Scapy?

I am trying to identify packets with incorrect checksums while using Scapy as a sniffer. I am able to get the original checksum by开发者_开发问答 accessing

packet[TCP].chksum  

I then remove this using

del packet[TCP].chksum 

I would like to do something like

if(originalChecksum == recomputedChecksum):
     # Checksum is valid

I understand that using show2() recomputes the checksum, but is there anyway to access this attribute for comparing back to the original? Calling show2() simply displays what the checksum would be, and does not set any of the values in the packet.

Thanks for any clarification


to make Scapy recompute all fields, assemble the packet by dumping it to a string, then parse the string.

originalChecksum=packet['TCP'].chksum
del packet['TCP'].chksum
packet=IP(str(packet))
recomputedChecksum=packet['TCP'].chksum
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜