Last active
July 7, 2023 11:43
-
-
Save thepacketgeek/6928674 to your computer and use it in GitHub Desktop.
Simple DNS Query with Scapy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scapy.all import * | |
answer = sr1(IP(dst="8.8.8.8")/UDP(dport=53)/DNS(rd=1,qd=DNSQR(qname="www.thepacketgeek.com")),verbose=0) | |
print answer[DNS].summary() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I suggest getting some DNS bins online to track your requests. In this case I used requestbin.net
Here is an example that works
>>> ans = sr1(IP(dst="8.8.8.8")/UDP(sport=RandShort(), dport=53)/DNS(rd=1,qd=DNSQR(qname="7a645c14a2eaac.d.requestbin.net",qtype="A")))
Begin emission:
Finished to send 1 packets.
*
Received 1 packets, got 1 answers, remaining 0 packets
>>> **ans.an.rdata**
'127.0.0.1'