secdev / scapy

Scapy: the Python-based interactive packet manipulation program & library.
https://scapy.net
GNU General Public License v2.0
10.58k stars 2.01k forks source link

Errno 11001 when trying to import scapy.all #1248

Closed IamIdan closed 6 years ago

IamIdan commented 6 years ago

Hello everyone! I have a very strange error when trying to import scapy:

>>> from scapy.all import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "scapy\all.py", line 25, in <module>
    from scapy.route import *
  File "scapy\route.py", line 193, in <module>
    iface = conf.route.route("0.0.0.0", verbose=0)[0]
  File "scapy\route.py", line 155, in route
    aa = atol(a)
  File "scapy\utils.py", line 425, in atol
    ip = inet_aton(socket.gethostbyname(x))
socket.gaierror: [Errno 11001] getaddrinfo failed

Can someone tell me what I need to do in order to fix this bug? I'm using the development version from here on Windows 10, python 2.7.11

IamIdan commented 6 years ago

I am willing to check it myself If someone could tell me a way in which I could debug this (print seems to not do anything? also cant open the file with PyCharm because every Import of scapy.something is an error)

guedou commented 6 years ago

Could you share your routing table? Better, could you share the value of self.routes at scapy/routes.py line 152.

IamIdan commented 6 years ago

@guedou Sorry for the delay :) self.routes value is: <type 'list'>: [(4294967295L, 4294967295L, '0.0.0.0', <NetworkInterface Realtek PCIe FE Family Controller {C6AD049F-F868-4804-9DF9-1B44CBF26796}>, ''), (4294967295L, 4294967295L, '0.0.0.0', <NetworkInterface LogMeIn Hamachi Virtual Ethernet Adapter {CF7A25AB-83F8-4007-94B6-1E71A930DCE6}>, 'fe80::d857:7790:cf6b:b18d'), (4294967295L, 4294967295L, '0.0.0.0', <NetworkInterface Qualcomm Atheros QCA9377 Wireless Network Adapter {EEFBC70D-0FA6-4750-910E-01A3946DF611}>, '10.100.102.13'), (3758096384L, 4026531840L, '0.0.0.0', <NetworkInterface Realtek PCIe FE Family Controller {C6AD049F-F868-4804-9DF9-1B44CBF26796}>, ''), (3758096384L, 4026531840L, '0.0.0.0', <NetworkInterface LogMeIn Hamachi Virtual Ethernet Adapter {CF7A25AB-83F8-4007-94B6-1E71A930DCE6}>, 'fe80::d857:7790:cf6b:b18d'), (3758096384L, 4026531840L, '0.0.0.0', <NetworkInterface Qualcomm Atheros QCA9377 Wireless Network Adapter {EEFBC70D-0FA6-4750-910E-01A3946DF611}>, '10.100.102.13'), (174352127, 4294967295L, '0.0.0.0', <NetworkInterface Qualcomm Atheros QCA9377 Wireless Network Adapter {EEFBC70D-0FA6-4750-910E-01A3946DF611}>, '10.100.102.13'), (174352127, 4294967295L, '0.0.0.0', <NetworkInterface Realtek PCIe FE Family Controller {C6AD049F-F868-4804-9DF9-1B44CBF26796}>, ''), (174351885, 4294967295L, '0.0.0.0', <NetworkInterface Qualcomm Atheros QCA9377 Wireless Network Adapter {EEFBC70D-0FA6-4750-910E-01A3946DF611}>, '10.100.102.13'), (174351877, 4294967295L, '0.0.0.0', <NetworkInterface Realtek PCIe FE Family Controller {C6AD049F-F868-4804-9DF9-1B44CBF26796}>, ''), (174351872, 4294967040L, '0.0.0.0', <NetworkInterface Qualcomm Atheros QCA9377 Wireless Network Adapter {EEFBC70D-0FA6-4750-910E-01A3946DF611}>, '10.100.102.13'), (174351872, 4294967040L, '0.0.0.0', <NetworkInterface Realtek PCIe FE Family Controller {C6AD049F-F868-4804-9DF9-1B44CBF26796}>, ''), (0, 0L, '10.100.102.1', <NetworkInterface Qualcomm Atheros QCA9377 Wireless Network Adapter {EEFBC70D-0FA6-4750-910E-01A3946DF611}>, '10.100.102.13'), (0, 0L, '10.100.102.1', <NetworkInterface Realtek PCIe FE Family Controller {C6AD049F-F868-4804-9DF9-1B44CBF26796}>, ''), (0, 0L, '25.0.0.1', <NetworkInterface LogMeIn Hamachi Virtual Ethernet Adapter {CF7A25AB-83F8-4007-94B6-1E71A930DCE6}>, 'fe80::d857:7790:cf6b:b18d')] Also, the routing table content is:

C:\WINDOWS\system32>netstat -rn
===========================================================================
Interface List
 14...1c 39 47 df 3d b5 ......Realtek PCIe FE Family Controller
 15...7a 79 19 5d 24 b9 ......LogMeIn Hamachi Virtual Ethernet Adapter
 17...76 df bf 5c c0 6b ......Microsoft Wi-Fi Direct Virtual Adapter
 18...74 df bf 5c c0 6b ......Qualcomm Atheros QCA9377 Wireless Network Adapter
  1...........................Software Loopback Interface 1
===========================================================================

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0         25.0.0.1                f   9256
          0.0.0.0          0.0.0.0     10.100.102.1    10.100.102.13     55
     10.100.102.0    255.255.255.0         On-link     10.100.102.13    311
    10.100.102.13  255.255.255.255         On-link     10.100.102.13    311
   10.100.102.255  255.255.255.255         On-link     10.100.102.13    311
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    331
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    331
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    331
        224.0.0.0        240.0.0.0         On-link         127.0.0.1    331
        224.0.0.0        240.0.0.0         On-link     10.100.102.13    311
        224.0.0.0        240.0.0.0         On-link                 f   9256
  255.255.255.255  255.255.255.255         On-link         127.0.0.1    331
  255.255.255.255  255.255.255.255         On-link     10.100.102.13    311
  255.255.255.255  255.255.255.255         On-link                 f   9256
===========================================================================
Persistent Routes:
  Network Address          Netmask  Gateway Address  Metric
          0.0.0.0          0.0.0.0         25.0.0.1  Default
===========================================================================

IPv6 Route Table
===========================================================================
Active Routes:
 If Metric Network Destination      Gateway
 15   9015 ::/0                     2620:9b::1900:1
  1    331 ::1/128                  On-link
 15    271 2620:9b::/64             On-link
 15    271 2620:9b::/96             On-link
 15    271 2620:9b::195d:24b9/128   On-link
 18    311 fe80::/64                On-link
 15    271 fe80::/64                On-link
 18    311 fe80::19a0:370f:5afa:668f/128
                                    On-link
 15    271 fe80::d857:7790:cf6b:b18d/128
                                    On-link
  1    331 ff00::/8                 On-link
 18    311 ff00::/8                 On-link
 15    271 ff00::/8                 On-link
===========================================================================
Persistent Routes:
 If Metric Network Destination      Gateway
  0 4294967295 2620:9b::/96             On-link
  0   9000 ::/0                     2620:9b::1900:1
===========================================================================

Thanks for your time!

guedou commented 6 years ago

@gpotter2 any idea?

gpotter2 commented 6 years ago

Would be great if @lamldan could retry using the latest development version (the provided routes have no metrics and must be quite old). If it still not works, please provide the result of the following:

IamIdan commented 6 years ago

So I've installed the last development version, and I it still fails with the same error. so as @guedou asked me in the first post, here is self.routes table: https://pastebin.com/ENtVxVwF Routing table: https://pastebin.com/VddifeXf

Also adding the new information as @gpotter2 asked: Get-NetRoute results: https://pastebin.com/HjVchPku Get_NetAdapter results: https://pastebin.com/cAGSk2h8

Wanted to add that in the crash line, ip = inet_aton(socket.gethostbyname(x)), x value is equal to 'fe80::d857:7790:cf6b:b18d'.

Again, thank you both :)

gpotter2 commented 6 years ago

Your bug seems impossible: the problem is that you have some IPv6 routes inside the IPv4 only routing system: https://pastebin.com/ENtVxVwF

(4294967295L, 4294967295L, '0.0.0.0', <NetworkInterface LogMeIn Hamachi Virtual Ethernet Adapter {CF7A25AB-83F8-4007-94B6-1E71A930DCE6}>, 'fe80::d857:7790:cf6b:b18d', 9256)

Where as it’s content is based on the result of https://pastebin.com/HjVchPku Which clearly does not contain any IPv6.

Could you return the content of the

scapy.arch.windows.read_routes()

You might be able to import only this function from a python shell

Either it’s a weirdo bug, or you have some piece of code adding ipv6 routes to conf.routes (for ipv6, it’s conf.routes6)

gpotter2 commented 6 years ago

Hello @IamIdan, is your issue fixed ?

guedou commented 6 years ago

Closed due to no activity.