Skip to content

Commit c02f976

Browse files
committed
Fix critical bugs in result.py and target.py
Critical bug fix - ignore_target() never matched ignored targets: - Line 204: `ignored_target == 'IGN'` compared a dict to a string, always evaluating to False. Fixed to `ignored_target.get('type') == 'IGN'`. This caused duplicate ignored targets to accumulate in cracked.json. Bug fix - load_ignored_bssids() used wrong dict key: - Used `item.get('result_type')` but the JSON schema uses `type` key. This caused ignored BSSIDs to never be loaded, meaning previously ignored targets would be attacked again on restart. Bug fix - hidden ESSID detection missed actual null bytes: - Added `'\x00' * essid_len` check alongside the existing literal text representations ('\\x00' and 'x00') to catch all forms of hidden ESSID encoding from airodump-ng. Code quality: - Replace `raise Exception()` with `raise NotImplementedError()` in abstract base class methods (dump, to_dict, print_single_line) - Remove unnecessary `global result` variable in load() method All 575 tests pass. https://claude.ai/code/session_015S3rdrYgPHPLA4hWo6yr5g
1 parent 1b153e5 commit c02f976

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

wifite/model/result.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ def __init__(self):
2020
self.readable_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(self.date))
2121

2222
def dump(self):
23-
raise Exception('Unimplemented method: dump()')
23+
raise NotImplementedError('Subclasses must implement dump()')
2424

2525
def to_dict(self):
26-
raise Exception('Unimplemented method: to_dict()')
26+
raise NotImplementedError('Subclasses must implement to_dict()')
2727

2828
def print_single_line(self, longest_essid):
29-
raise Exception('Unimplemented method: print_single_line()')
29+
raise NotImplementedError('Subclasses must implement print_single_line()')
3030

3131
def print_single_line_prefix(self, longest_essid):
3232
essid = self.essid or 'N/A'
@@ -129,12 +129,12 @@ def load_all(cls):
129129
return json
130130

131131
@classmethod
132-
def load_ignored_bssids(cls, ignore_cracked = False):
132+
def load_ignored_bssids(cls, ignore_cracked=False):
133133
json = cls.load_all()
134134
ignored_bssids = [
135135
item.get('bssid', '')
136136
for item in json
137-
if item.get('result_type') == 'IGN'
137+
if item.get('type') == 'IGN'
138138
]
139139

140140
if not ignore_cracked:
@@ -143,13 +143,13 @@ def load_ignored_bssids(cls, ignore_cracked = False):
143143
return ignored_bssids + [
144144
item.get('bssid', '')
145145
for item in json
146-
if item.get('result_type') != 'IGN'
146+
if item.get('type') != 'IGN'
147147
]
148148

149149
@staticmethod
150150
def load(json):
151151
""" Returns an instance of the appropriate object given a json instance """
152-
global result
152+
result = None
153153
if json['type'] == 'WPA':
154154
from .wpa_result import CrackResultWPA
155155
result = CrackResultWPA(bssid=json['bssid'],
@@ -201,7 +201,7 @@ def ignore_target(cls, target):
201201
ignored_targets = cls.load_all()
202202

203203
for ignored_target in ignored_targets:
204-
is_ignored = ignored_target == 'IGN'
204+
is_ignored = ignored_target.get('type') == 'IGN'
205205
bssid_match = target.bssid == ignored_target.get('bssid')
206206
essid_match = target.essid == ignored_target.get('essid')
207207
if is_ignored and bssid_match and essid_match:

wifite/model/target.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def __init__(self, fields):
124124
self.essid = fields[13]
125125
if self.essid == '\\x00' * self.essid_len or \
126126
self.essid == 'x00' * self.essid_len or \
127+
self.essid == '\x00' * self.essid_len or \
127128
self.essid.strip() == '':
128129
# Don't display '\x00...' for hidden ESSIDs
129130
self.essid = None # '(%s)' % self.bssid

0 commit comments

Comments
 (0)