SHARE
TWEET

Python DNS Packet Sniffer

a guest Aug 4th, 2015 2,413 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /usr/bin/python
  2.  
  3. from scapy.all import *
  4. import sys
  5.  
  6. try:
  7.         interface = raw_input("[*] Enter Desired Interface: ")
  8. except KeyboardInterrupt:
  9.         print "[*] User Requested Shutdown..."
  10.         print "[*] Exiting..."
  11.         sys.exit(1)
  12.  
  13. def querysniff(pkt):
  14.         if IP in pkt:
  15.                 ip_src = pkt[IP].src
  16.                 ip_dst = pkt[IP].dst   
  17.                 if pkt.haslayer(DNS) and pkt.getlayer(DNS).qr == 0:
  18.                         print str(ip_src) + " -> " + str(ip_dst) + " : " + "(" + pkt.getlayer(DNS).qd.qname + ")"
  19.  
  20. sniff(iface = interface,filter = "port 53", prn = querysniff, store = 0)
  21. print "\n[*] Shutting Down..."
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top