将 TCP 校验和与 Scapy 进行比较? [英] Comparing TCP checksums with Scapy?

查看:62
本文介绍了将 TCP 校验和与 Scapy 进行比较?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 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  

然后我使用

del packet[TCP].chksum 

我想做类似的事情

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

我知道使用 show2() 会重新计算校验和,但是无论如何都可以访问此属性以与原始属性进行比较?调用 show2() 只是显示校验和是什么,并且不会设置数据包中的任何值.

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.

感谢您的澄清

推荐答案

让 Scapy 重新计算所有字段,通过将其转储为字符串来组装数据包,然后解析该字符串.

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

这篇关于将 TCP 校验和与 Scapy 进行比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆