简体   繁体   English

为scapy添加新协议(类似于ARP)

[英]Adding a new protocol to scapy (Similiar to ARP)

I would like to implement a new secure ARP protocol that is immune to ARP poisoning. 我想实现一个不受ARP中毒影响的新安全ARP协议。 The new "SecureArp" will hold a signature field that can be checked against an agreed upon hmac function. 新的“SecureArp”将保存一个签名字段,可以根据商定的hmac函数进行检查。 The scapy definition is as follows: scapy的定义如下:

  class SecureArp(Packet):
  name = "SecureARP"
  fields_desc = [IPField("srcip", None),
               MACField("srcmac", None),
               IPField("dstip", None),
               MACField("dstmac", "00:00:00:00:00:00"),
               IntEnumField("opcode", 1, { 1: "request", 2: "response" }),
               StrFixedLenField("challenge", "", length=24),
               StrFixedLenField("signature", "", length=20)]

The problem I encounter is that when receiving such SecureArp message scapy doesn't parse it at all and leaves the data as "Raw". 我遇到的问题是,当收到这样的SecureArp消息时,scapy根本不解析它并将数据保留为“Raw”。 I read the SecDev documentation about extending to a new protocol and its very unclear. 我阅读了关于扩展到新协议的SecDev文档并且非常不清楚。 What steps should i take so a SecureArp packet received would be automatically parsed? 我应该采取哪些步骤,以便自动解析收到的SecureArp数据包? Thanks 谢谢

You'll have to bind your layer to another one in order for scapy to auto dissect it. 你必须将你的图层绑定到另一个图层才能让scapy自动剖析它。

Also see scapys ARP implementation. 另请参阅scapys ARP实现。

bind_layers( Ether,         ARP,           type=2054)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM