scapy icon indicating copy to clipboard operation
scapy copied to clipboard

__del__: don't know how to close the file descriptor

Open stack66 opened this issue 10 years ago • 32 comments

Scapy ver.2.3.2 -command sr1(IP(dst="94.180.250.119")/TCP(dport=80,flags="S")) on Windows XP

stack66 avatar Feb 09 '16 14:02 stack66

Hi,

Can you be more specific (e.g., add the entire stack trace if available)?

p-l- avatar Feb 09 '16 15:02 p-l-

I have found the same issue:

romero:scapy-2.3.2 romerojnr$ sudo ./run_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?)
INFO: Can't import python Crypto lib. Won't be able to decrypt WEP.
INFO: Can't import python Crypto lib. Disabled certificate manipulation tools
Welcome to Scapy (2.3.2)
>>> import sys
>>> print sys.version
2.7.11 (default, Jan 22 2016, 08:29:18)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)]
>>> pkt = IP()
>>> send(pkt)
.WARNING: __del__: don't know how to close the file descriptor. Bugs ahead ! Please report this bug.

Sent 1 packets.
>>>

ghost avatar Mar 19 '16 11:03 ghost

Thanks @romerojnr! Could you try with the current development version and let us know if the bug still exists? Windows support has been significantly updated since 2.3.2 has been released.

p-l- avatar Mar 19 '16 12:03 p-l-

The same error occurred after testing it from the development version. However, I'm not running Windows, I'm running OS X El Capitan (10.11.3). Can I provide you with any other information or output?

romero:scapy-master romerojnr$ uname -a
Darwin romero.local 15.3.0 Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64
romero:scapy-master romerojnr$ sudo ./run_scapy
Python 2.7.11
INFO: Can't import matplotlib. 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?)
INFO: Can't import python Crypto lib. Won't be able to decrypt WEP.
WARNING: can't import layer ipsec: No module named Crypto.Util.number
INFO: Can't import python Crypto lib. Disabled certificate manipulation tools
Welcome to Scapy (2.3.2-dev)
>>> import sys
>>> print sys.version
2.7.11 (default, Jan 22 2016, 08:29:18)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)]
>>> pkt = IP()
>>> send(pkt)
.WARNING: __del__: don't know how to close the file descriptor. Bugs ahead ! Please report this bug.

Sent 1 packets.
>>> exit()

ghost avatar Mar 20 '16 09:03 ghost

Do you have the same problem when you try to send an "actual" packet (i.e., not to 127.0.0.1, with a payload, etc.)? For example: send(IP(dst="www.google.fr")/ICMP()).

p-l- avatar Mar 20 '16 11:03 p-l-

Same behaviour...

>>> send(IP(dst="www.google.com")/ICMP())
.WARNING: __del__: don't know how to close the file descriptor. Bugs ahead ! Please report this bug.

ghost avatar Mar 20 '16 12:03 ghost

Apparently this was added in the commit 6d7f110566ee9c2f6828645f00c7f995fa9888d1, nothing really changed except for the annoying warning message.

ghost avatar Mar 20 '16 13:03 ghost

@romerojnr could you provide me the following information ? Thanks.

  1. is the packet being sent ?
  2. how did you install Scapy ?
  3. how did you install pcap ? It seems that it is not a generic pcap binding that we support but we can fix that
  4. what is the output of the variables conf.L2listen conf.L2socket and conf.L3socket ? You can directly type them in Scapy prompt

You will be happy to read that I am making some progress for OS X native support. Hopefuly, I will be able to provide a PR in the next few weeks.

guedou avatar Mar 22 '16 14:03 guedou

I use scapy on windows and I met the same issue, the packet has been send, and I install scapy with pip, I download pcap via url blow, pcap http://files.cnblogs.com/Jerryshome/pcap-1.1.win32-py2.7.rar

conf.L2listen <L2pcapListenSocket: read packets at layer 2 using libpcap>

conf.L2socket <L2dnetSocket: read/write packets at layer 2 using libdnet and libpcap>

conf.L3socket <L3dnetSocket: read/write packets at layer 3 using libdnet and libpcap>

the error msg is: WARNING: del: don't know how to close the file descriptor. Bugs ahead ! Please report this bug. WARNING: Mac address to reach destination not found. Using broadcast. .WARNING: del: don't know how to close the file descriptor. Bugs ahead ! Please report this bug.

Sent 1 packets.

felixzhang1 avatar Apr 08 '16 09:04 felixzhang1

Same issue

holynakamoto avatar Jun 09 '16 04:06 holynakamoto

Which version of Scapy are you using and on which operating systems ?

guedou avatar Jun 10 '16 08:06 guedou

Happening here for me as well with latest development version on master, commit fa6067faab66fa54f355da18b9667992c279e082 using pypcap (installed via pip2)

OSX 10.11.5 Darwin MacBook-Pro.local 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64

Card info if it could be useful:

Card Type:            AirPort Extreme  (0x14E4, 0x152)
Firmware Version:     Broadcom BCM43xx 1.0 (7.21.95.175.1a6)
Country Code:         AU
Supported PHY Modes:  802.11 a/b/g/n/ac
Supported Channels:   1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 144, 149, 153, 157, 161, 165
Wake On Wireless:     Supported
AirDrop:              Supported, Channel 149

Using this script (with a fixed interface name) because I have to test some stuff.

Traceback (most recent call last):
  File "server.py", line 19, in <module>
    sniff(filter='udp port 53', iface='en0', store=0, prn=dns_spoof)
  File "/usr/local/lib/python2.7/site-packages/scapy/sendrecv.py", line 617, in sniff
    r = prn(p)
  File "server.py", line 12, in dns_spoof
    send(spoofed_pkt)
  File "/usr/local/lib/python2.7/site-packages/scapy/sendrecv.py", line 265, in send
    return __gen_send(conf.L3socket(*args, **kargs), x, inter=inter, loop=loop, count=count,verbose=verbose,
  File "/usr/local/lib/python2.7/site-packages/scapy/supersocket.py", line 65, in __init__
    self.ins = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(type))
AttributeError: 'module' object has no attribute 'AF_PACKET'
WARNING: __del__: don't know how to close the file descriptor. Bugs ahead ! Please report this bug.

If any more info could be useful, let me know. Thanks for the help, scapy looks like a great tool :)

DanielOaks avatar Jun 21 '16 05:06 DanielOaks

@DanielOaks it looks like that you did not install mandatory Python modules (i.e. dnet & pcap bindings), as you are hiting Linux only code. On OS X, Scapy does not run natively yet (see Issue #104).

I will suggest that you pick any of the following you:

  • give a try to scapy-bpf. That is the native OS X support that I will soon be merged.
  • install packages using Homebrew:
brew update
brew install --with-python libdnet
brew install https://raw.githubusercontent.com/secdev/scapy/master/.travis/pylibpcap.rb
  • install packages using macports: port install py-libdnet py-pylibpcap It should fix this issue.

In the mean tine, I will update the doc and finish the OS X native support.

guedou avatar Jun 21 '16 15:06 guedou

This is happening for me as well! Is it fixed? Does it affect the functionality of the code. I've been getting this warning when I run scripts using Scapy,

WARNING: more fileno: pcapy API does not permit to get capure file descriptor. Bugs ahead! Press Enter to trigger packet reading
WARNING: __del__: don't know how to close the file descriptor. Bugs ahead ! Please report this bug.

PS: I've installed Scapy in a FreeBSD 10.1-RELEASE-p25 machine. I installed the two basic dependencies using pkg install py27-libdnet and pkg install py27-pcap and scapy was installed by downloading its source.

itshari avatar Jul 08 '16 10:07 itshari

@itshari thanks for reporting the issue. Could you give us a small example that could help us to fix the issue ? Thanks.

In the mean time could you try with scapy-bpf ? Thanks.

guedou avatar Jul 08 '16 12:07 guedou

I am having the same issue

from scapy.all import *

def arp_display(put):
  if pkt[ARP].op == 1: #who-has (request)
     print "ARP Probe from: " + pkt[ARP].hwsrc

print sniff(prn=arp_display, filter="arp", store=0, count=10)


128keaton avatar Jul 09 '16 17:07 128keaton

Which operating systems do you use ?

Sent from my iPhone

On 9 juil. 2016, at 19:57, Keaton Burleson [email protected] wrote:

I am having the same issue

from scapy.all import *

def arp_display(put): if pkt[ARP].op == 1: #who-has (request) print "ARP Probe from: " + pkt[ARP].hwsrc

print sniff(prn=arp_display, filter="arp", store=0, count=10)

― You are receiving this because you were assigned. Reply to this email directly, view it on GitHub, or mute the thread.

guedou avatar Jul 09 '16 22:07 guedou

@guedou OS X 10.11.4

128keaton avatar Jul 09 '16 22:07 128keaton

@128keaton I can not reproduce the issue using your example. Did you install dependencies as described in the documentation ?

guedou avatar Jul 11 '16 07:07 guedou

Got the same error, mac OS 10.10.5

johnson7788 avatar Jul 21 '16 05:07 johnson7788