python - 使用 scapy 生成 LACP 流量
问题描述
我需要使用 scapy 生成 STP 和 LACP 流量。我已经为 STP 做到了:
from scapy.all import STP
import scapy
from scapy.all import *
data='test'
a=Dot3(dst="01:00:0c:cc:cc:cd", src="08:17:35:51:29:2e")/LLC(dsap=0xaa, ssap=0xaa, ctrl=3)/SNAP(OUI=0x0c, code=0x010b)/STP(rootid=8406, portid=0x802e, pathcost=19, rootmac="2c:33:11:53:85:80",bridgeid=32982, bridgemac="08:17:35:51:29:00", bpdutype=128)/data
sendp(a,iface="eth2", count=200)
但是我被 LACP 流量的生成阻止了,我试图关注scapy.contrib.lacp但我不明白如何使用它
解决方案
在生成中,您应该让 scapy 放置链接层的协议类型。
import scapy.all as scapy
from scapy.layers.inet import Ether, Dot3
from scapy.contrib.lacp import SlowProtocol, LACP
from scapy.layers.l2 import LLC, SNAP, STP
data='test'
pkt = Dot3(dst="01:00:0c:cc:cc:cd", src="08:17:35:51:29:2e") \
/ LLC(dsap=0xaa, ssap=0xaa, ctrl=3) \
/ SNAP(OUI=0x0c, code=0x010b) \
/ STP(rootid=8406, portid=0x802e, pathcost=19, rootmac="2c:33:11:53:85:80",bridgeid=32982, bridgemac="08:17:35:51:29:00", bpdutype=128) \
/ data
pkt.show2()
sendp(pkt, iface="eth2", count=200)
pkt = Ether() / SlowProtocol() / LACP()
pkt.show2()
sendp(pkt, iface="eth2", count=200)
推荐阅读
- excel - 基于循环遍历具有 300 万行的 txt 文件中的值的 excel 匹配值的文本匹配 [慢]
- firebase - Firebase - 从数据库/firestore 数据执行分析
- windows - Windows(窗体)应用项目建议
- html - CSS adjacent sibling selector fails when parent element class is added
- mysql - 如何为多个用户 ID 和多天选择每天的最后一个时间戳读数?
- google-apps-script - Gmail 应用脚本 - 从 Gmail 标签而不是 Gmail 收件箱中提取电子邮件内容
- visual-c++ - 丢失指针事件(队列溢出?)
- php - Make multidimensional array with php and pdo
- python - Replace NaNs for month N with the value for month (N - 1) in Pandas DataFrame
- ios - 是否可以在 Apple App Store 上列出两个开发者?