Martin
Martin

Reputation: 77

Scapy fails to send ipv6 packets

Hello everyone i am new here so please be kind.

I have been using scapy lately in order to send and recieve ipv6 packets to selected ipv6 enabled servers. The gist of the code is here:

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)

When i execute the code hoever this is what i get:

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

From what i understand, the packet has been sent nevertheless a response is never gotten(0 answers). This made me think of using wireshark to sniff the packet.

Upon using it with filter:

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

I realised the packet was never sent at the first place! Does anyone know why this is happening or what is hapening here?

Regards Martinos

EDIT:

On closer inspection from comments, i realized that the route list SHOULD not be empty. There are no routes to send the packet. I am not sure how to add them! Please help here is what i did:

i tried to get all the interfaces from my device. Here is what i got back:

{'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}

As you can see, nowhere in there there is an ipv6 address. How am i supposed to send ipv6 packets if no ipv6 address is listed? in extend, here is the ipconfig from cmd:

    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

This is run on a VM but i dont think it matters.

PLEASE someone help me this is very important! how can i configure scapy in order to understand how to send ipv6 packets. and why do i see no ipv6 addresses in the list above of interfaces?

Upvotes: 2

Views: 9236

Answers (4)

Koala
Koala

Reputation: 27

The fact that @thuovila answer was accepted seems questionable to me. From the settings you can see that ipv6 is configured correctly, even if a ping -6 ipv6.google.com would not get a reply, it is unlikely that no packets would be seen on the interface. The question was more about why scapy does not send any packets out of the desired interface. @Surya answer was the most helpful because it showed you how to check in scapy out of which interface the packet was leaving.

But I will add my answer to it, because the final solution to your problem is to set scapy to send the packets out of the desired interface with conf.iface = "your interface"

Upvotes: 0

Surya
Surya

Reputation: 75

I observed that in "layers/inet6.py" there is function call to getmacbyip6, in which they are trying to get the interface info based on the scapy routing table.

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

As conf.iface6 is set to "lo" by default it always return loopback interface.

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

I changed the above statement as shown below then I was able to see the packets going out from the corresponding interface.

Example:-

[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

Upvotes: 1

Runa Barik
Runa Barik

Reputation: 1

conf.iface6 should be set for sending IPv6 packets.

Upvotes: -1

thuovila
thuovila

Reputation: 2020

The ethernet adapter indeed has both an IPv6 address and a default gateway. You could

  • Try to ping -6 ipv6.google.com to see if there is any IPv6 connectivity. I think there must be, since I can ping your IPv6 address just fine, unless it has been reassigned to somebody else now.

  • Inspect the routing tables to see there are no superfluous routes In particular, the Teredo interface might be causing trouble. Turn it off. (netsh interface teredo set state disabled)

Teredo: https://www.rfc-editor.org/rfc/rfc4380 http://en.wikipedia.org/wiki/Teredo_tunneling

I do not know how to configure IPv6 routing and interfaces using scapy.

I made this an answer, since there is not enough room in the comments. I do still suggest you ask on superuser. I can not sufficiently help you, since I am not familiar with either "JANET" or Windows networking configuration.

Upvotes: 2

Related Questions