I want to print only when i got actual mac address else wait
import time
capture = pyshark.LiveCapture(interface='wlo2', bpf_filter='arp')
capture.sniff(timeout=3)
keys = {}
e_mac = '00.00.00.00.00.00'
for packet in capture:
keys['ip'] = packet.arp.dst_proto_ipv4
keys['mac'] = packet.arp.dst_hw_mac
if keys['mac'] != e_mac:
print(time.strftime('%b %d %H:%M:%S '), keys['mac'], keys['ip'])
output:
Dec 06 12:57:08 00:00:00:00:00:00 192.168.1.40
Dec 06 12:59:53 00:00:00:00:00:00 192.168.1.40
Dec 06 13:01:46 00:00:00:00:00:00 192.168.1.195
Dec 06 13:01:55 f8:c4:f3:56:a3:70 192.168.1.1
Dec 06 13:08:24 00:00:00:00:00:00 192.168.1.5
import time
capture = pyshark.LiveCapture(interface='wlo2', bpf_filter='arp')
capture.sniff(timeout=3)
keys = {}
e_mac = '00:00:00:00:00:00' #forgot to add colon in ques
for packet in capture:
keys['ip'] = packet.arp.dst_proto_ipv4
keys['mac'] = packet.arp.dst_hw_mac
if keys['mac'] != e_mac:
print(time.strftime('%b %d %H:%M:%S '), keys['mac'], keys['ip'])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.