(self)
Sniff raw ARP packets
Sniff raw ARP packets
Sniff raw ARP packets
def sniff(self):
        """Sniff raw ARP packets"""
        try:
            sock = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.ntohs(0x0806))
            while True:
                data = sock.recv(512)
                if self.sender_ip(data) == self.remote and data[42] != '\x00':
                    self.remote_mac = self.sender_mac(data)
                    self.handle(data[42:].replace('\x00', ''))
        except Exception, e:
            print e
def sniff ( self ) : try : sock = socket . socket ( socket . AF_PACKET , socket . SOCK_RAW , socket . ntohs ( 0x0806 ) ) while True : data = sock . recv ( 512 ) if self . sender_ip ( data ) == self . remote and data [ 42 ] != '\x00' : self . remote_mac = self . sender_mac ( data ) self . handle ( data [ 42 : ] . replace ( '\x00' , '' ) ) except Exception , e : print e