首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Python:用Scapy发送IGMP数据包

Python:用Scapy发送IGMP数据包
EN

Stack Overflow用户
提问于 2014-04-06 09:07:13
回答 2查看 11.9K关注 0票数 3

我想用替罪羊发送IGMP数据包,特别是IGMP离开,IGMP会员报告。是否可以这样做呢?

更新:

我最终产生了它们。必须做以下工作:

1)按照这里所描述的(包括setup.py中的小改动)安装舟桥v.2.2.0:在窗户和软呢帽上安装了替身后,失去了替罪羊的肋骨

2)您需要使用来自贡献包的文件(没有添加到替罪羊核心的特性):

代码语言:javascript
运行
复制
import scapy.contrib.igmp
igmpPacket = scapy.contrib.igmp.IGMP()
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-04-06 10:20:53

是的,可以发送IGMP数据包。在搜索了一点之后,我找到了一些有用的链接,可以帮助您在某个方向。在github上存在一个IGMPIGMPv3实现。这里也有一个有趣的邮寄名单。而且,这个帖子还有一个与IGMP相关的有趣的东西。

票数 3
EN

Stack Overflow用户

发布于 2016-10-08 10:46:02

使用此方法,您可以发送IGMP 2 (RFC2236)成员资格查询消息,而不是IGMP 3。

下面是完整的代码和tcpdump:

代码语言:javascript
运行
复制
>>> from scapy.all import *
>>> import scapy.contrib.igmp
>>> p = IP(dst="62.22.14.4")/scapy.contrib.igmp.IGMP()
>>> send(p)
.
Sent 1 packets.
>>>

# tcpdump -ni cplane0 igmp
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on cplane0, link-type EN10MB (Ethernet), capture size 262144 bytes
18:42:01.045618 IP 44.60.11.3 > 62.22.14.4: igmp query v2 [max resp time 20]
18:42:01.045631 IP 44.60.11.3 > 62.22.14.4: igmp query v2 [max resp time 20]
18:42:01.046470 IP 44.60.11.3 > 62.22.14.4: igmp query v2 [max resp time 20]
18:42:01.046476 IP 44.60.11.3 > 62.22.14.4: igmp query v2 [max resp time 20]
18:42:01.959331 IP 62.22.14.4 > 224.1.1.1: igmp v2 report 224.1.1.1

更新:因为IGMPv3正在建设中。下面是发送IGMP版本3成员资格查询的一种方法:

代码语言:javascript
运行
复制
>>> from scapy.all import *
>>>
>>> class IGMP3(Packet):
...     name = "IGMP3"
...     fields_desc = [ ByteField("type", 0x11),
...                     ByteField("mrtime", 20),
...                   XShortField("chksum", None),
...                       IPField("gaddr", "0.0.0.0"),
...                      IntField("others", 0x0)]
...     def post_build(self, p, pay):
...         p += pay
...         if self.chksum is None:
...             ck = checksum(p)
...             p = p[:2]+chr(ck>>8)+chr(ck&0xff)+p[4:]
...         return p
...
>>> bind_layers( IP, IGMP3, frag=0, proto=2)
>>> p = IP(dst="62.21.20.21")/IGMP3()
>>> send(p)
.
Sent 1 packets.
>>>

# tcpdump -ni cplane0 igmp -v
tcpdump: listening on cplane0, link-type EN10MB (Ethernet), capture size     262144 bytes
17:24:35.013987 IP (tos 0x0, ttl 62, id 1, offset 0, flags [none], proto IGMP (2), length 32)
44.60.11.3 > 62.21.20.21: igmp query v3 [max resp time 2.0s]
17:24:35.014000 IP (tos 0x0, ttl 62, id 1, offset 0, flags [none], proto IGMP (2), length 32)
44.60.11.3 > 62.21.20.21: igmp query v3 [max resp time 2.0s]
17:24:35.014476 IP (tos 0x0, ttl 62, id 1, offset 0, flags [none], proto IGMP (2), length 32)
44.60.11.3 > 62.21.20.21: igmp query v3 [max resp time 2.0s]
17:24:35.014482 IP (tos 0x0, ttl 62, id 1, offset 0, flags [none], proto IGMP (2), length 32)
44.60.11.3 > 62.21.20.21: igmp query v3 [max resp time 2.0s]
17:24:35.218208 IP (tos 0xc0, ttl 1, id 0, offset 0, flags [DF], proto IGMP (2), length 40, options (RA))
62.21.20.21 > 224.0.0.22: igmp v3 report, 1 group record(s) [gaddr 239.1.1.1 is_ex, 0 source(s)]
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22891990

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档