From 0d2b46fde550f32422f74ce648fc820130bb4a53 Mon Sep 17 00:00:00 2001 From: Markus Donko-Huber Date: Thu, 29 Aug 2019 21:16:04 +0200 Subject: [PATCH] normalize mac address from scapy --- roles/arp/files/apate/lib/apate_redis.py | 3 ++- roles/fingerprinting/files/registrar/lib/misc_thread.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/roles/arp/files/apate/lib/apate_redis.py b/roles/arp/files/apate/lib/apate_redis.py index 086ed272..fdc96593 100644 --- a/roles/arp/files/apate/lib/apate_redis.py +++ b/roles/arp/files/apate/lib/apate_redis.py @@ -267,13 +267,14 @@ def check_device_disabled(self, mac): """ # True if devices is disabled # return self.redis.get(self._get_device_name(mac, network or self.network, enabled=False)) is not None - return self.redis.sismember(self.get_excluded_key(), mac) + return self.redis.sismember(self.get_excluded_key(), str(mac).lower()) def _toggle_device(self, mac, ip, network, enabled): # add new device first and delete old device afterwards # this is done to avoid race conditions # self.add_device(mac, self.get_device_ip(mac, network, enabled=not enabled), network, enabled=enabled, force=True) # self.remove_device(mac, network, enabled=not enabled) + mac = str(mac).lower() if not enabled: self.redis.sadd(self.get_excluded_key(), mac) else: diff --git a/roles/fingerprinting/files/registrar/lib/misc_thread.py b/roles/fingerprinting/files/registrar/lib/misc_thread.py index c90fde16..67d93774 100644 --- a/roles/fingerprinting/files/registrar/lib/misc_thread.py +++ b/roles/fingerprinting/files/registrar/lib/misc_thread.py @@ -63,8 +63,10 @@ def run(self): if devices: ans, unans = arping(devices, iface=None, verbose=0) for device in ans: - if check_preconditions(device[1][ARP].psrc, device[1][ARP].hwsrc): - insert_or_update_fingerprint(self.conn, ip=device[1][ARP].psrc, mac=device[1][ARP].hwsrc) + ip_addr = device[1][ARP].psrc + mac_addr = str(device[1][ARP].hwsrc).lower() + if check_preconditions(ip_addr, mac_addr): + insert_or_update_fingerprint(self.conn, ip=ip_addr, mac=mac_addr) self.logger.info("checked no mode devices: " + str(devices))