File tree Expand file tree Collapse file tree 4 files changed +36
-0
lines changed
Expand file tree Collapse file tree 4 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -373,6 +373,11 @@ def _add_global_args(self, glob):
373373 dest = 'ignore_cracked' ,
374374 help = Color .s ('Hides previously-cracked targets. (default: {G}off{W})' ))
375375
376+ glob .add_argument ('--ignore-captured' ,
377+ action = 'store_true' ,
378+ dest = 'ignore_captured' ,
379+ help = Color .s ('Hides targets with existing captured handshakes/pmkid. (default: {G}off{W})' ))
380+
376381 glob .add_argument ('--clients-only' ,
377382 action = 'store_true' ,
378383 dest = 'clients_only' ,
Original file line number Diff line number Diff 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
@@ -729,6 +731,15 @@ def parse_settings_args(cls, args):
729731 else :
730732 Color .pl ('{!} {R}Previously-cracked access points not found in %s' % cls .cracked_file )
731733 cls .ignore_cracked = False
734+
735+ if args .ignore_captured :
736+ captured_bssids = CrackResult .load_captured_bssids (cls .wpa_handshake_dir )
737+ if captured_bssids :
738+ cls .ignore_captured = captured_bssids
739+ Color .pl ('{+} {C}option: {O}ignoring {R}%s{O} targets with existing captures' % len (captured_bssids ))
740+ else :
741+ Color .pl ('{!} {R}No captured handshakes/PMKIDs found in %s' % cls .wpa_handshake_dir )
742+
732743 if args .clients_only :
733744 cls .clients_only = True
734745 Color .pl ('{+} {C}option:{W} {O}ignoring targets that do not have associated clients' )
Original file line number Diff line number Diff line change 44from ..util .color import Color
55from ..config import Configuration
66
7+ import glob
78import os
9+ import re
810import time
911from 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 """
Original file line number Diff line number Diff 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 :
You can’t perform that action at this time.
0 commit comments