From ebdde675e9a7ade3ed3f487e2b930fb83aed3014 Mon Sep 17 00:00:00 2001 From: derv82 Date: Sun, 11 Jun 2017 17:48:19 -0400 Subject: [PATCH] Filter multicast/broadcast BSSIDs from appearing in target list Should resolve #32 --- py/Airodump.py | 15 +++++---------- py/Target.py | 23 +++++++++++++++++++++-- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/py/Airodump.py b/py/Airodump.py index 147bfef..3860c25 100644 --- a/py/Airodump.py +++ b/py/Airodump.py @@ -211,17 +211,12 @@ class Airodump(object): else: # The current row corresponds to a "Target" (router) - target = Target(row) + try: + target = Target(row) + targets.append(target) + except Exception: + continue - if target.essid_len == 0: - # Ignore empty/blank ESSIDs - pass - - if target.channel == "-1": - # Ignore -1 channel - pass - - targets.append(target) return targets @staticmethod diff --git a/py/Target.py b/py/Target.py index b743d3e..1e3b0d0 100644 --- a/py/Target.py +++ b/py/Target.py @@ -3,6 +3,8 @@ from Color import Color +import re + class Target(object): ''' Holds details for a "Target" aka Access Point (e.g. router). @@ -49,8 +51,8 @@ class Target(object): self.ivs = int(fields[10].strip()) self.essid_known = True - self.essid_len = int(fields[12].strip()) - self.essid = fields[13].strip() + self.essid_len = int(fields[12].strip()) + self.essid = fields[13].strip() if self.essid == '\\x00' * self.essid_len or self.essid.strip() == '': # Don't display "\x00..." for hidden ESSIDs self.essid = None # '(%s)' % self.bssid @@ -60,6 +62,23 @@ class Target(object): self.clients = [] + self.validate() + + def validate(self): + ''' Checks that the target is valid. ''' + if self.essid_len == 0: + raise Exception("Ignoring target with empty/blank ESSID (length: 0)") + elif self.channel == "-1": + raise Exception("Ignoring target with Negative-One (-1) channel") + + # Filter broadcast/multicast BSSIDs, see https://github.com/derv82/wifite2/issues/32 + bssid_broadcast = re.compile(r"^(ff:ff:ff:ff:ff:ff|00:00:00:00:00:00)$") + if bssid_broadcast.match(self.bssid): + raise Exception("Ignoring target with Broadcast BSSID (%s)" % self.bssid) + + bssid_multicast = re.compile(r"^(01:00:5e|01:80:c2|33:33)") + if bssid_multicast.match(self.bssid): + raise Exception("Ignoring target with Multicast BSSID (%s)" % self.bssid) def __str__(self): '''