#!/usr/bin/env python

from scapy.all import *
import sys

def callback(binding, f, s=0, c=0):
    sniff(prn=binding, filter=f, store=s, count=c)

def ip_monitor_callback(pkt):
    #only look at dns packets, and don't look at ours
    #otherwise infiinit loop
    if DNS in pkt and IP in pkt and pkt[IP].src != '1.1.1.1':
        # test to also see if it is a response rather than a request 
        # look to see if the udp source port is 53
        if pkt[UDP].sport == 53:
		# do another test to see if the query was for cit.dixie.edu 
                # you can test qd.qname
                qname = pkt[DNS].qd.qname.decode()
                if qname == "computing.utahtech.edu.":
                    print (pkt.show())

        
                    #NOW ADD YOUR CODE BELOW HERE.
                    #HERE ARE SOME HINTS

                    # if the above conditions are met
                    # create a new IP datagram that will send to my machine (ip)
                    # don't forget to make the src 1.1.1.1
                    # creaet a new UDP datagram with source port = 53 (doesn't matter what destination port is (udp)
                    # now create a message that looks like:
                    # ip/udp/pkt[DNS], where pkt[DNS] is the dns portion of the above pkt passed into this function
                    # add your lastname to that newly created packet
                    # change DNS answer to '3.3.3.3' (an section of DNS)
                    # send new packet        
                
        
                
def main():
    callback(ip_monitor_callback, "ip", 0, 0)
    

if __name__=="__main__":
    main()


