python-pcap模块解析mac地址

python-pcap模块解析mac地址

作者:vpoet

mail:[email protected]

 1 import pcap

 2 import binascii

 3 

 4 

 5 a = pcap.pcap()

 6 a.setfilter('arp')

 7 

 8 for i,j in a:

 9     if binascii.hexlify(j[21])=="02":

10         print 'Mac Reply!'

11         for index in range(len(j)):

12             if index>=22 and index<=27:

13                    print binascii.hexlify(j[index])+":"

14         print "Over"

15         break

16         


运行结果:

python-pcap模块解析mac地址

你可能感兴趣的:(python)