【问题标题】:Can't sniff Ethernet-type 0x0102 custom packet无法嗅探以太网类型 0x0102 自定义数据包
【发布时间】:2018-10-06 18:05:41
【问题描述】:

第一个问题是 Scapy 无法在 Ether-type 0x0102 上的自定义数据包下方嗅探。

计算.py ↓

from scapy.all import *

class calc(Packet):
    name = 'calc'
    fields_desc = [ BitEnumField('op',0,8,{1:'ADD',2:'SUM',3:'MUL'}),
                BitField('num1',0,32),
                BitField('num2',0,32)
                ]

send_calc.py ↓

from scapy.all import *
from calc import *

p = Ether(type=0x0102)/IP(dst='192.168.1.0')/ICMP()/calc(op=1,num1=2,num2=3)
sendp(p)

sniff_calc.py ↓

from scapy.all import *
from calc import *

sniff(filter='ether proto 0x0102 and host 192.168.1.0',prn=lambda x:x.show())

第二个问题是 Scapy 可以在将 Ether-type 设置为 0x800 时进行嗅探,但在 0x0102 上不起作用。

此外,结果将自定义 calc() 标头转换为 Raw。以下结果是对 Ether-type 0x0800 的嗅探。

....
###[ ICMP ]### 
    type      = echo-request
    code      = 0
    chksum    = 0xf1ff
    id        = 0x0
    seq       = 0x0
###[ Raw ]### 
       load      = '\x01\x00\x00\x00\x02\x00\x00\x00\x03'

我应该采取什么步骤来自动解析收到的 Calc 数据包并在 Ether-type 0x0102 上工作?谢谢

【问题讨论】:

  • 这不是一个有效的 EtherType,它们的值 >= 0x0600。您使用的是长度字段,而不是 EtherType。
  • 根据iana.org,0x0101-0x01FF 用于实验。你能告诉我这是什么意思吗?
  • 指定用于实验的两个 EtherType 是 0x88b50x88b6
  • 非常感谢您的热心教导!

标签: python networking scapy tcp-ip


【解决方案1】:

如果值为 >= 0x0600,则以太网标头中的该字段仅用作 EtherType 字段。如果该字段的值 0x5DC,则该字段被解释为有效负载长度字段。

您的值0x0102 将用作有效负载长度字段,而不是用作 EtherType。您需要选择适当的 EtherType 值。 IANA 维护具有已注册 EtherType 值的 IEEE 802 Numbers 页面,以及 所有分配的 EtherType 的 the IEEE maintains a page

如果您想进行实验,则需要使用为此分配的 EtherType:

88b5
IEEE 标准 802 - 本地 实验 Ethertype 1. 此 Ethertype 值可供公众使用 用于原型和供应商特定的协议开发,如 在 IEEE Std 802 修正案 802a 中定义。

-或-

88b6
IEEE Std 802 - Local Experimental Ethertype 2. 此 Ethertype 值 可供公众使用,也可用于原型和特定供应商 协议开发,如 IEEE Std 802 修正案 802a 中所定义。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-15
    • 1970-01-01
    • 1970-01-01
    • 2011-09-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多