Scapy无法发送ipv6数据包

2024-05-16 02:06:51 发布

您现在位置:Python中文网/ 问答频道 /正文

大家好,我是新来的,所以请友好。

我最近一直在使用scapy向选定的支持ipv6的服务器发送和接收ipv6数据包。代码的要点如下:

text = line[:-1]
            #destination=getIPv6Addr(line[:-1])
            destination="2607:f1c0:1000:60e0:7992:97f7:61b2:2814"
            source="2001:630:d0:f105:5cfe:e988:421a:a7b7"
            syn = IPv6(dst=destination,src=source) / TCP(sport=555,dport=80,flags="S")#flag S is syn packet
            syn.show()
            syn_ack = sr1(syn,timeout=11)

当我执行代码时,这就是我得到的:

Begin emission:
Finished to send 1 packets.
.................WARNING: No route found for IPv6 destination :: (no default route?)
WARNING: No route found for IPv6 destination 2607:f1c0:1000:60e0:7992:97f7:61b2:2814 (no default route?)
............................................................................................................
Received 1322 packets, got 0 answers, remaining 1 packets

据我所知,数据包已发送,但从未得到响应(0个答案)。这让我想到用wireshark来嗅数据包。

与过滤器一起使用时:

ip6 net 2607:f1c0:1000:60e0:7992:97f7:61b2:2814

我一开始就意识到包裹从来没有寄过!有人知道为什么会发生这样的事吗?这里有什么好消息吗?

问候 马提诺斯

编辑:

经过仔细查看评论,我意识到路线列表不应该是空的。没有发送数据包的路由。我不知道怎么加!请帮忙我是这么做的:

我试着从我的设备上获取所有的接口。这是我得到的:

{'flags': 33, 'link_addr': b0:90:20:52:41:53, 'type': 6, 'name': 'eth0', 'mtu': 1500L}
{'flags': 33, 'link_addr': b0:90:20:52:41:53, 'type': 6, 'name': 'eth1', 'mtu': 1500L}
{'flags': 33, 'link_addr': 00:50:56:a0:1e:df, 'type': 6, 'name': 'eth2', 'mtu': 1500L}
{'flags': 33, 'link_addr': 00:50:56:a0:1e:df, 'type': 6, 'name': 'eth3', 'mtu': 1500L}
{'flags': 33, 'link_addr': b0:90:20:52:41:53, 'type': 6, 'name': 'eth4', 'mtu': 1500L}
{'flags': 33, 'link_addr': b0:90:20:52:41:53, 'type': 6, 'name': 'eth5', 'mtu': 1500L}
{'flags': 32, 'link_addr': 00:50:56:a0:00:6c, 'type': 6, 'name': 'eth6', 'mtu': 0L}
{'flags': 32, 'link_addr': 00:50:56:a0:01:0e, 'type': 6, 'name': 'eth7', 'mtu': 0L}
{'flags': 32, 'link_addr': 00:50:56:a0:6e:61, 'type': 6, 'name': 'eth8', 'mtu': 0L}
{'addr': 152.78.61.39/24, 'mtu': 1500L, 'flags': 33, 'link_addr': 00:50:56:a0:1e:df, 'type': 6, 'name': 'eth9'}
{'flags': 33, 'link_addr': b0:90:20:52:41:53, 'type': 6, 'name': 'eth10', 'mtu': 1500L}
{'flags': 33, 'link_addr': b0:90:20:52:41:53, 'type': 6, 'name': 'eth11', 'mtu': 1500L}
{'flags': 33, 'type': 23, 'name': 'ppp0', 'mtu': 1494L}
{'flags': 33, 'link_addr': 20:41:53:59:4e:ff, 'type': 23, 'name': 'ppp1', 'mtu': 3256L}
{'addr': 127.0.0.1/8, 'flags': 3, 'type': 24, 'name': 'lo0', 'mtu': 1500L}
{'flags': 33, 'type': 131, 'name': 'tun0', 'mtu': 4091L}
{'flags': 32, 'type': 131, 'name': 'tun1', 'mtu': 1480L}
{'flags': 33, 'type': 131, 'name': 'tun2', 'mtu': 1460L}
{'flags': 33, 'type': 131, 'name': 'tun3', 'mtu': 1464L}
{'flags': 32, 'type': 131, 'name': 'tun4', 'mtu': 1280L}
{'flags': 32, 'type': 131, 'name': 'tun5', 'mtu': 1280L}
{'flags': 33, 'type': 131, 'name': 'tun6', 'mtu': 1472L}
{'flags': 32, 'type': 131, 'name': 'tun7', 'mtu': 1280L}

如你所见,没有任何地方有ipv6地址。如果没有列出ipv6地址,我应该如何发送ipv6数据包?在extend中,这里是来自cmd的ipconfig:

    Ethernet adapter Local Area Connection 4:

   Connection-specific DNS Suffix  . : ecs.soton.ac.uk
   IPv6 Address. . . . . . . . . . . : 2001:630:d0:f105:5cfe:e988:421a:a7b7
   Temporary IPv6 Address. . . . . . : 2001:630:d0:f105:e8bc:7c26:9a40:31b8
   Link-local IPv6 Address . . . . . : fe80::5cfe:e988:421a:a7b7%17
   IPv4 Address. . . . . . . . . . . : 152.78.61.39
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : fe80::210:18ff:fee5:5bfa%17
                                       152.78.61.254

Tunnel adapter 6TO4 Adapter:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Tunnel adapter Teredo Tunneling Pseudo-Interface:

   Connection-specific DNS Suffix  . :
   IPv6 Address. . . . . . . . . . . : 2001:0:5ef5:79fd:142e:398d:67b1:c2d8
   Link-local IPv6 Address . . . . . : fe80::142e:398d:67b1:c2d8%13
   Default Gateway . . . . . . . . . :

Tunnel adapter isatap.ecs.soton.ac.uk:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : ecs.soton.ac.uk

这是在虚拟机上运行的,但我认为这不重要。

请有人帮我这很重要!如何配置scapy以了解如何发送ipv6数据包。为什么在上面的接口列表中看不到ipv6地址?


Tags: nameaddresstypelinkconnectionb0数据包a0
3条回答

以太网适配器确实有一个IPv6地址和一个默认网关。你可以

  • 尝试ping -6 ipv6.google.com查看是否有IPv6连接。我想一定有,因为我可以很好地ping你的IPv6地址,除非它已经被重新分配给其他人了。

  • 检查路由表,看是否没有多余的路由 尤其是Teredo接口可能会引起问题。关掉它。 (netsh interface teredo set state disabled)

特雷多: http://tools.ietf.org/html/rfc4380http://en.wikipedia.org/wiki/Teredo_tunneling

我不知道如何使用scapy配置IPv6路由和接口。

我是这样回答的,因为评论没有足够的空间。我还是建议你问问超级用户。我无法充分帮助您,因为我不熟悉“JANET”或Windows网络配置。

我注意到在“layers/inet6.py”中有一个对getmacbyip6的函数调用,在这个函数中,他们试图根据scapy路由表获取接口信息。

iff,a,nh = conf.route6.route(ip6, dev=conf.iface6)

由于conf.iface6默认设置为“lo”,它总是返回环回接口。

iff,a,nh = conf.route6.route(ip6)

我更改了上面的语句,如下所示,然后我就可以看到数据包从相应的接口发出。

示例:-

[root@purple-perf-tester scapy]# ifconfig eth1
eth1: flags=323<UP,BROADCAST,RUNNING,PROMISC>  mtu 1500
        inet 11.0.0.5  netmask 255.255.255.0  broadcast 0.0.0.0
        inet6 2001::6  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::f816:3eff:fe2b:cc67  prefixlen 64  scopeid 0x20<link>
        ether fa:16:3e:2b:cc:67  txqueuelen 1000  (Ethernet)
        RX packets 6107709  bytes 1239209940 (1.1 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12093723  bytes 4161092991 (3.8 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@purple-perf-tester scapy]# ip -6 route show dev eth1
2001::7 via fe80::f816:3eff:fed1:43de  metric 1024 
2001::/64  proto kernel  metric 256 
fe80::/64  proto kernel  metric 256 

[root@purple-perf-tester scapy]# scapy
INFO: Can't import python gnuplot wrapper . Won't be able to plot.
INFO: Can't import PyX. Won't be able to use psdump() or pdfdump().
WARNING: No route found for IPv6 destination :: (no default route?)

Welcome to Scapy (2.3.1)
>>> 
>>> conf.route6
Destination                    Next Hop                   iface  src candidates           
::1/128                        ::                         lo     ::1                      
2001::7/128                    fe80::f816:3eff:fed1:43de  eth1   2001::6                  
2001::/64                      ::                         eth1   2001::6                  
2002::/64                      ::                         eth2   2002::6                  
fe80::/64                      ::                         eth0   fe80::f816:3eff:fe7c:d9fe
fe80::/64                      ::                         eth1   fe80::f816:3eff:fe2b:cc67
fe80::/64                      ::                         eth2   fe80::f816:3eff:fe1a:a62e
::1/128                        ::                         lo     ::1                      
2001::6/128                    ::                         lo     ::1                      
2002::6/128                    ::                         lo     ::1                      
fe80::f816:3eff:fe1a:a62e/128  ::                         lo     ::1                      
fe80::f816:3eff:fe2b:cc67/128  ::                         lo     ::1                      
fe80::f816:3eff:fe7c:d9fe/128  ::                         lo     ::1                      
>>> iff,a,nh = conf.route6.route("2001::7", dev=conf.iface6)
WARNING: No route found for IPv6 destination 2001::7 (no default route?)
>>> print iff
lo
>>> iff,a,nh = conf.route6.route("2001::7")
>>> print iff
eth1

应设置conf.iface6以发送IPv6数据包。

相关问题 更多 >