#!/opt/local/bin/python # dnslib from https://pypi.python.org/pypi/dnslib, install with "pip install dnslib" # When using a local copy of dnslib: # import sys # sys.path.append('~sergey/cs60/dns/dnslib-0.9.7') or wherever the downloaded copy lives from scapy.all import * from dnslib import * l = rdpcap("recursive-dns-lookup-noDNSSEC.pcap") for pp in l : print "\n-------------------[ %s -> %s ]-------------------" % (pp[IP].src , pp[IP].dst) d = DNSRecord.parse(str(pp)[0x2a:]) print(d)