Skip to content

Commit 34a7610

Browse files
committed
code: cleanup
1 parent ee3c2ae commit 34a7610

10 files changed

Lines changed: 166 additions & 166 deletions

File tree

wifite/attack/all.py

100644100755
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ def attack_multiple(cls, targets, session=None, session_mgr=None):
5555
if index % 5 == 0: # Every 5 targets
5656
from ..util.process import Process
5757
Process.check_fd_limit()
58-
58+
5959
# Memory monitoring - especially important for infinite mode
6060
MemoryMonitor.periodic_check(index)
61-
61+
6262
# Infinite mode specific cleanup
6363
if infinite_monitor and index % 10 == 0:
6464
infinite_monitor.on_target_complete()
@@ -111,25 +111,25 @@ def attack_single(cls, target, targets_remaining, session=None, session_mgr=None
111111

112112
elif target.primary_encryption.startswith('WPA'): # Covers WPA, WPA2, WPA3
113113
# WPA can have multiple attack vectors:
114-
114+
115115
# Check if this is a WPA3 target
116116
is_wpa3 = target.primary_encryption == 'WPA3' or \
117-
(hasattr(target, 'wpa3_info') and target.wpa3_info and
117+
(hasattr(target, 'wpa3_info') and target.wpa3_info and
118118
(hasattr(target.wpa3_info, 'has_wpa3') and target.wpa3_info.has_wpa3))
119-
119+
120120
# For WPA3 targets, use specialized WPA3 attack if tools are available
121121
if is_wpa3 and WPA3ToolChecker.can_attack_wpa3():
122122
# Use WPA3-specific attack module
123123
attacks.append(AttackWPA3SAE(target))
124-
124+
125125
# For transition mode, also try standard WPA2 attacks as fallback
126126
if hasattr(target, 'wpa3_info') and target.wpa3_info and target.wpa3_info.get('is_transition'):
127127
if not Configuration.wps_only and not Configuration.use_pmkid_only:
128128
# Add PMKID and WPA attacks as fallback for transition mode
129129
if not Configuration.dont_use_pmkid:
130130
attacks.append(AttackPMKID(target))
131131
attacks.append(AttackWPA(target))
132-
132+
133133
# WPS attacks (not applicable to pure WPA3)
134134
elif not is_wpa3 and \
135135
not Configuration.use_pmkid_only and \

wifite/attack/pmkid.py

100644100755
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def get_existing_pmkid_file(bssid):
6666
pmkid_pattern = os.path.join(Configuration.wpa_handshake_dir, 'pmkid_*.22000')
6767
files_found = glob.glob(pmkid_pattern)
6868
log_debug('AttackPMKID', f'Found {len(files_found)} PMKID file(s) to check')
69-
69+
7070
for pmkid_filename in files_found:
7171
if not os.path.isfile(pmkid_filename):
7272
continue
@@ -141,15 +141,15 @@ def run_hashcat(self):
141141
return False
142142

143143
from ..util.process import Process
144-
144+
145145
# Check tool availability - prioritize hcxdumptool, fallback to native
146146
use_native_pmkid = False
147147
dependencies = [
148148
HcxDumpTool.dependency_name,
149149
HcxPcapngTool.dependency_name
150150
]
151151
missing_deps = [dep for dep in dependencies if not Process.exists(dep)]
152-
152+
153153
if missing_deps:
154154
# Check if native PMKID capture is available as fallback
155155
if NATIVE_PMKID_AVAILABLE:
@@ -528,22 +528,22 @@ def dumptool_thread(self):
528528
def capture_pmkid_native(self):
529529
"""
530530
Capture PMKID using native Scapy implementation.
531-
531+
532532
This is a fallback method when hcxdumptool is not available.
533533
Uses ScapyPMKID to capture PMKID by sending auth frames and
534534
listening for EAPOL Message 1 responses.
535-
535+
536536
Returns:
537537
Path to PMKID hash file (.22000) if captured, None otherwise
538538
"""
539539
log_info('AttackPMKID', f'Starting native PMKID capture for {self.target.essid} ({self.target.bssid})')
540-
540+
541541
if self.view:
542542
self.view.add_log("Starting native PMKID capture (Scapy)...")
543543
self.view.set_capture_tool("Native (Scapy)")
544-
544+
545545
Color.pattack('PMKID', self.target, 'CAPTURE', 'Starting native capture...')
546-
546+
547547
try:
548548
# Set interface to target channel
549549
from ..native.interface import NativeInterface
@@ -553,17 +553,17 @@ def capture_pmkid_native(self):
553553
log_debug('AttackPMKID', f'Set channel to {self.target.channel}')
554554
except Exception as e:
555555
log_warning('AttackPMKID', f'Could not set channel: {e}')
556-
556+
557557
# Capture PMKID with timeout
558558
timeout = Configuration.pmkid_timeout
559559
self.timer = Timer(timeout)
560-
560+
561561
# Track progress for TUI
562562
def on_pmkid_captured(result):
563563
log_info('AttackPMKID', f'Native capture found PMKID: {result.pmkid[:16]}...')
564564
if self.view:
565565
self.view.add_log(f'PMKID captured!')
566-
566+
567567
# Use ScapyPMKID capture
568568
result = ScapyPMKID.capture(
569569
interface=Configuration.interface,
@@ -574,7 +574,7 @@ def on_pmkid_captured(result):
574574
channel=int(self.target.channel) if self.target.channel else None,
575575
callback=on_pmkid_captured
576576
)
577-
577+
578578
if result is None:
579579
log_warning('AttackPMKID', 'Native PMKID capture failed: no PMKID received')
580580
if self.view:
@@ -583,22 +583,22 @@ def on_pmkid_captured(result):
583583
Color.pattack('PMKID', self.target, 'CAPTURE', '{R}Failed{O} to capture PMKID (native)\n')
584584
Color.pl('')
585585
return None
586-
586+
587587
# Success - convert to hashcat format and save
588588
log_info('AttackPMKID', 'Native PMKID capture successful')
589589
if self.view:
590590
self.view.update_pmkid_status(True, 1)
591591
self.view.add_log("Successfully captured PMKID (native)!")
592-
592+
593593
Color.clear_entire_line()
594594
Color.pattack('PMKID', self.target, 'CAPTURE', '{G}Captured PMKID{W} (native)')
595-
595+
596596
# Generate hashcat 22000 format
597597
pmkid_hash = result.to_hashcat_22000()
598-
598+
599599
# Save to file
600600
return self.save_pmkid(pmkid_hash)
601-
601+
602602
except Exception as e:
603603
log_error('AttackPMKID', f'Native PMKID capture error: {e}', e)
604604
if self.view:

wifite/attack/wpa.py

100644100755
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,27 @@
2121

2222

2323
class AttackWPA(Attack):
24-
24+
2525
# Maximum retry attempts for recoverable errors
2626
MAX_RETRY_ATTEMPTS = 3
2727
RETRY_DELAY_SECONDS = 2
28-
28+
2929
def __init__(self, target):
3030
super(AttackWPA, self).__init__(target)
3131
self.clients = []
3232
self.crack_result = None
3333
self.success = False
34-
34+
3535
# Interface assignment for dual interface support
3636
self.interface_assignment = None
3737
self.capture_interface = None # Dedicated interface for handshake capture
3838
self.deauth_interface = None # Dedicated interface for deauthentication
39-
39+
4040
# Error recovery tracking
4141
self._retry_count = 0
4242
self._last_error = None
4343
self._recovered_from_error = False
44-
44+
4545
# Initialize TUI view if in TUI mode
4646
self.view = None
4747
if OutputManager.is_tui_mode():
@@ -51,18 +51,18 @@ def __init__(self, target):
5151
except Exception:
5252
# If TUI initialization fails, continue without it
5353
self.view = None
54-
54+
5555
@contextmanager
5656
def _error_recovery_context(self, operation_name: str):
5757
"""
5858
Context manager for automatic error recovery during WPA attacks.
59-
59+
6060
Handles common recoverable errors:
6161
- Interface going down
6262
- Channel switching failures
6363
- Resource exhaustion
6464
- Process crashes
65-
65+
6666
Args:
6767
operation_name: Name of operation for logging
6868

wifite/attack/wpa3.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,33 +67,33 @@ def run(self):
6767
4. Selects optimal attack strategy
6868
5. Executes the selected strategy
6969
6. Falls back to alternative strategies if needed
70-
70+
7171
Returns:
7272
bool: True if attack succeeded, False otherwise
7373
"""
7474
# Check for required WPA3 tools
7575
if not self._check_wpa3_tools():
7676
return False
77-
77+
7878
# Start TUI view if available
7979
if self.view:
8080
self.view.start()
81-
81+
8282
# Detect WPA3 capabilities
8383
self.wpa3_info = WPA3Detector.detect_wpa3_capability(self.target)
84-
84+
8585
# Check for Dragonblood vulnerabilities
8686
self._check_dragonblood_vulnerability()
87-
87+
8888
# Select attack strategy
8989
self.attack_strategy = WPA3AttackStrategy.select_strategy(
90-
self.target,
90+
self.target,
9191
self.wpa3_info
9292
)
93-
93+
9494
# Display strategy to user
9595
self._display_strategy()
96-
96+
9797
# Execute strategy based on selection
9898
if self.attack_strategy == WPA3AttackStrategy.DOWNGRADE:
9999
return self._execute_downgrade_strategy()

0 commit comments

Comments
 (0)