I want to use the Python module scapy to perform an equivalent command of
dig ANY google.com @8.8.4.4 +notcp
I've made a simple example code:
from scapy.all import *
a = sr(IP(dst="8.8.4.4")/UDP(sport=RandShort(),dport=53)/DNS(qd=DNSQR(qname="google.com",qtype="ALL",qclass="IN")))
print str(a[0])
And it sends and receives a packet, but when I sniffed the packet the response says Server failure
.
Sniffing the dig
command itself, looks nearly the same but it gives me a correct response and also it does not send another ICMP - Destination unreachable
Packet.. this only comes up when sending it with scapy.
If you need more information, feel free to ask. Maybe someone can help me with this..
EDIT:
Maybe the ICMP - Destination unreachable
packet were send because 8.8.4.4
tries to send the response to my sport
, which is closed? But why should dig
then work?!
Got the Python code working with scapy..
srp(Ether()/IP(src="192.168.1.101",dst="8.8.8.8")/UDP(sport=RandShort(),dport=53)/DNS(rd=1,qd=DNSQR(qname="google.com",qtype="ALL",qclass="IN"),ar=DNSRROPT(rclass=3000)),timeout=1,verbose=0)
In Wireshark we can see now a correct response: Wireshark Screenshot
But I'm still getting the ICMP - Destination unreachable
packet..
and I don't know why..