Skip to content

Commit aef6760

Browse files
authored
Merge pull request #464 from rpodgorny/ignore-captured
Add --ignore-captured flag
2 parents 3b2e927 + f17e13e commit aef6760

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

wifite/args.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,11 @@ def _add_global_args(self, glob):
397397
dest='ignore_cracked',
398398
help=Color.s('Hides previously-cracked targets. (default: {G}off{W})'))
399399

400+
glob.add_argument('--ignore-captured',
401+
action='store_true',
402+
dest='ignore_captured',
403+
help=Color.s('Hides targets with existing captured handshakes/pmkid. (default: {G}off{W})'))
404+
400405
glob.add_argument('--clients-only',
401406
action='store_true',
402407
dest='clients_only',

wifite/config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Configuration:
3434
encryption_filter = None
3535
existing_commands = None
3636
five_ghz = None
37+
ignore_captured = None
3738
ignore_cracked = None
3839
ignore_essids = None
3940
ignore_old_handshakes = None
@@ -204,6 +205,7 @@ def initialize(cls, load_interface=True):
204205
cls.target_essid = None # User-defined AP name
205206
cls.target_bssid = None # User-defined AP BSSID
206207
cls.ignore_essids = None # ESSIDs to ignore
208+
cls.ignore_captured = False # Ignore targets with existing captures
207209
cls.ignore_cracked = False # Ignore previously-cracked BSSIDs
208210
cls.clients_only = False # Only show targets that have associated clients
209211
cls.all_bands = False # Scan for both 2Ghz and 5Ghz channels
@@ -744,6 +746,15 @@ def parse_settings_args(cls, args):
744746
else:
745747
Color.pl('{!} {R}Previously-cracked access points not found in %s' % cls.cracked_file)
746748
cls.ignore_cracked = False
749+
750+
if args.ignore_captured:
751+
captured_bssids = CrackResult.load_captured_bssids(cls.wpa_handshake_dir)
752+
if captured_bssids:
753+
cls.ignore_captured = captured_bssids
754+
Color.pl('{+} {C}option: {O}ignoring {R}%s{O} targets with existing captures' % len(captured_bssids))
755+
else:
756+
Color.pl('{!} {R}No captured handshakes/PMKIDs found in %s' % cls.wpa_handshake_dir)
757+
747758
if args.clients_only:
748759
cls.clients_only = True
749760
Color.pl('{+} {C}option:{W} {O}ignoring targets that do not have associated clients')

wifite/model/result.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
from ..util.color import Color
55
from ..config import Configuration
66

7+
import glob
78
import os
9+
import re
810
import time
911
from json import loads, dumps
1012

@@ -146,6 +148,21 @@ def load_ignored_bssids(cls, ignore_cracked=False):
146148
if item.get('type') != 'IGN'
147149
]
148150

151+
@classmethod
152+
def load_captured_bssids(cls, hs_dir):
153+
"""Scan hs_dir for captured handshake/PMKID files and return list of BSSIDs."""
154+
bssids = set()
155+
if not os.path.isdir(hs_dir):
156+
return []
157+
158+
bssid_re = re.compile(r'^(?:handshake|pmkid)_.+_([0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2})_', re.IGNORECASE)
159+
for fname in os.listdir(hs_dir):
160+
m = bssid_re.match(fname)
161+
if m:
162+
bssids.add(m.group(1).replace('-', ':').upper())
163+
164+
return list(bssids)
165+
149166
@staticmethod
150167
def load(json):
151168
""" Returns an instance of the appropriate object given a json instance """

wifite/tools/airodump.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@ def filter_targets(targets5, skip_wps=False):
404404
elif Configuration.ignore_cracked and \
405405
result[i].bssid in Configuration.ignore_cracked:
406406
result.pop(i)
407+
elif Configuration.ignore_captured and \
408+
result[i].bssid in Configuration.ignore_captured:
409+
result.pop(i)
407410
elif bssid and result[i].bssid.lower() != bssid.lower():
408411
result.pop(i)
409412
elif essid and result[i].essid and result[i].essid != essid:

0 commit comments

Comments
 (0)