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!
- #! /usr/bin/python
- from scapy.all import *
- import sys
- interface = raw_input("[*] Enter Desired Interface: ")
- except KeyboardInterrupt:
- print "[*] User Requested Shutdown..."
- print "[*] Exiting..."
- def querysniff(pkt):
- if IP in pkt:
- ip_src = pkt[IP].src
- ip_dst = pkt[IP].dst
- if pkt.haslayer(DNS) and pkt.getlayer(DNS).qr == 0:
- print str(ip_src) + " -> " + str(ip_dst) + " : " + "(" + pkt.getlayer(DNS).qd.qname + ")"
- sniff(iface = interface,filter = "port 53", prn = querysniff, store = 0)
- print "\n[*] Shutting Down..."
RAW Paste Data