Skip to content

Commit 16d4778

Browse files
authored
Merge pull request #456 from kimocoder/claude/scan-project-issues-rodxf
Fix 5 bugs: TypeError in Attack class, native module crash, unsafe in…
2 parents b43444b + f48defb commit 16d4778

File tree

14 files changed

+95
-38
lines changed

14 files changed

+95
-38
lines changed

wifite/attack/eviltwin.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -974,11 +974,18 @@ def _check_dependencies(self) -> bool:
974974
True if all dependencies are available, False otherwise
975975
"""
976976
try:
977-
# TODO: Implement dependency checking
978-
# This will be implemented in task 6.2
979-
log_info('EvilTwin', 'Dependency check passed (placeholder)')
977+
from ..util.process import Process
978+
missing = []
979+
for tool in ['hostapd', 'dnsmasq']:
980+
if not Process.exists(tool):
981+
missing.append(tool)
982+
if missing:
983+
log_error('EvilTwin', f'Missing required tools: {", ".join(missing)}')
984+
self.error_message = f'Missing required tools: {", ".join(missing)}'
985+
return False
986+
log_info('EvilTwin', 'All required dependencies found')
980987
return True
981-
988+
982989
except Exception as e:
983990
log_error('EvilTwin', f'Dependency check failed: {e}', e)
984991
self.error_message = f'Dependency check failed: {e}'

wifite/attack/pmkid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
try:
2323
from ..native.pmkid import ScapyPMKID, PMKIDResult as NativePMKIDResult
2424
NATIVE_PMKID_AVAILABLE = ScapyPMKID.is_available()
25-
except ImportError:
25+
except BaseException:
2626
NATIVE_PMKID_AVAILABLE = False
2727

2828

wifite/model/attack.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
class Attack:
99
"""Contains functionality common to all attacks."""
1010

11-
target_wait = min(60, Configuration.wpa_attack_timeout)
11+
@staticmethod
12+
def _get_target_wait():
13+
"""Get target wait time, safely handling uninitialized Configuration."""
14+
timeout = Configuration.wpa_attack_timeout
15+
if timeout is None:
16+
return 60
17+
return min(60, timeout)
1218

1319
def __init__(self, target):
1420
self.target = target
@@ -18,12 +24,13 @@ def run(self):
1824

1925
def wait_for_target(self, airodump):
2026
"""Waits for target to appear in airodump."""
27+
target_wait = Attack._get_target_wait()
2128
start_time = time.time()
2229
targets = airodump.get_targets(apply_filter=False)
2330
while len(targets) == 0:
2431
# Wait for target to appear in airodump.
25-
if int(time.time() - start_time) > Attack.target_wait:
26-
raise Exception(f'Target did not appear after {Attack.target_wait:d} seconds, target may be out of range or turned off')
32+
if int(time.time() - start_time) > target_wait:
33+
raise Exception(f'Target did not appear after {target_wait:d} seconds, target may be out of range or turned off')
2734
time.sleep(1)
2835
targets = airodump.get_targets()
2936
continue

wifite/model/target.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ def __init__(self, fields):
111111
elif len(self.encryption) == 0: # Default to WPA if not specified, as per old logic
112112
self.primary_encryption = 'WPA'
113113
else: # Fallback for unknown types
114-
self.primary_encryption = self.encryption.split(' ')[0]
114+
parts = self.encryption.split(' ')
115+
self.primary_encryption = parts[0] if parts and parts[0] else 'WPA'
115116

116117

117118
if 'SAE' in self.authentication:

wifite/native/__init__.py

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,54 @@
2323
- scapy >= 2.6.1 (already a project dependency)
2424
"""
2525

26-
from .mac import NativeMac
27-
from .deauth import ScapyDeauth, ContinuousDeauth as NativeDeauth
28-
from .handshake import ScapyHandshake
29-
from .wps import ScapyWPS, WPSInfo
30-
from .interface import NativeInterface, InterfaceInfo
31-
from .pmkid import ScapyPMKID, PMKIDResult, PMKIDCapture
32-
from .scanner import ChannelHopper, NativeScanner, AccessPoint, Client
33-
from .beacon import BeaconGenerator, create_fake_ap as create_beacon
26+
try:
27+
from .mac import NativeMac
28+
except BaseException:
29+
NativeMac = None
30+
31+
try:
32+
from .deauth import ScapyDeauth, ContinuousDeauth as NativeDeauth
33+
except BaseException:
34+
ScapyDeauth = None
35+
NativeDeauth = None
36+
37+
try:
38+
from .handshake import ScapyHandshake
39+
except BaseException:
40+
ScapyHandshake = None
41+
42+
try:
43+
from .wps import ScapyWPS, WPSInfo
44+
except BaseException:
45+
ScapyWPS = None
46+
WPSInfo = None
47+
48+
try:
49+
from .interface import NativeInterface, InterfaceInfo
50+
except BaseException:
51+
NativeInterface = None
52+
InterfaceInfo = None
53+
54+
try:
55+
from .pmkid import ScapyPMKID, PMKIDResult, PMKIDCapture
56+
except BaseException:
57+
ScapyPMKID = None
58+
PMKIDResult = None
59+
PMKIDCapture = None
60+
61+
try:
62+
from .scanner import ChannelHopper, NativeScanner, AccessPoint, Client
63+
except BaseException:
64+
ChannelHopper = None
65+
NativeScanner = None
66+
AccessPoint = None
67+
Client = None
68+
69+
try:
70+
from .beacon import BeaconGenerator, create_fake_ap as create_beacon
71+
except BaseException:
72+
BeaconGenerator = None
73+
create_beacon = None
3474

3575
__all__ = [
3676
# MAC manipulation
@@ -80,49 +120,49 @@ def check_native_availability() -> dict:
80120
try:
81121
from .mac import NativeMac
82122
status['mac'] = True
83-
except ImportError:
123+
except BaseException:
84124
status['mac'] = False
85125

86126
try:
87127
from .deauth import SCAPY_AVAILABLE
88128
status['deauth'] = SCAPY_AVAILABLE
89-
except ImportError:
129+
except BaseException:
90130
status['deauth'] = False
91131

92132
try:
93133
from .handshake import SCAPY_AVAILABLE
94134
status['handshake'] = SCAPY_AVAILABLE
95-
except ImportError:
135+
except BaseException:
96136
status['handshake'] = False
97137

98138
try:
99139
from .wps import SCAPY_AVAILABLE
100140
status['wps'] = SCAPY_AVAILABLE
101-
except ImportError:
141+
except BaseException:
102142
status['wps'] = False
103143

104144
try:
105145
from .interface import NativeInterface
106146
status['interface'] = True
107-
except ImportError:
147+
except BaseException:
108148
status['interface'] = False
109149

110150
try:
111151
from .pmkid import SCAPY_AVAILABLE
112152
status['pmkid'] = SCAPY_AVAILABLE
113-
except ImportError:
153+
except BaseException:
114154
status['pmkid'] = False
115155

116156
try:
117157
from .scanner import SCAPY_AVAILABLE
118158
status['scanner'] = SCAPY_AVAILABLE
119-
except ImportError:
159+
except BaseException:
120160
status['scanner'] = False
121161

122162
try:
123163
from .beacon import SCAPY_AVAILABLE
124164
status['beacon'] = SCAPY_AVAILABLE
125-
except ImportError:
165+
except BaseException:
126166
status['beacon'] = False
127167

128168
return status
@@ -156,5 +196,5 @@ def print_native_status():
156196
import scapy
157197
scapy_version = scapy.VERSION if hasattr(scapy, 'VERSION') else 'unknown'
158198
print(f"\nScapy Version: {scapy_version}")
159-
except ImportError:
199+
except BaseException:
160200
print("\nScapy: Not Installed")

wifite/native/beacon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
sendp, sniff, conf as scapy_conf
3232
)
3333
SCAPY_AVAILABLE = True
34-
except ImportError:
34+
except BaseException:
3535
SCAPY_AVAILABLE = False
3636

3737

wifite/native/deauth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
sendp, conf as scapy_conf
4646
)
4747
SCAPY_AVAILABLE = True
48-
except ImportError:
48+
except BaseException:
4949
SCAPY_AVAILABLE = False
5050

5151

wifite/native/handshake.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
Dot11Elt, Raw, conf as scapy_conf
3939
)
4040
SCAPY_AVAILABLE = True
41-
except ImportError:
41+
except BaseException:
4242
SCAPY_AVAILABLE = False
4343

4444

wifite/native/pmkid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
sniff, sendp, conf as scapy_conf
4444
)
4545
SCAPY_AVAILABLE = True
46-
except ImportError:
46+
except BaseException:
4747
SCAPY_AVAILABLE = False
4848

4949

wifite/native/scanner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
sniff, conf as scapy_conf
4242
)
4343
SCAPY_AVAILABLE = True
44-
except ImportError:
44+
except BaseException:
4545
SCAPY_AVAILABLE = False
4646

4747

0 commit comments

Comments
 (0)