-
Notifications
You must be signed in to change notification settings - Fork 277
Fix 5 bugs: TypeError in Attack class, native module crash, unsafe in… #456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,7 +111,8 @@ def __init__(self, fields): | |
| elif len(self.encryption) == 0: # Default to WPA if not specified, as per old logic | ||
| self.primary_encryption = 'WPA' | ||
| else: # Fallback for unknown types | ||
| self.primary_encryption = self.encryption.split(' ')[0] | ||
| parts = self.encryption.split(' ') | ||
| self.primary_encryption = parts[0] if parts and parts[0] else 'WPA' | ||
|
Comment on lines
+114
to
+115
|
||
|
|
||
|
|
||
| if 'SAE' in self.authentication: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,14 +23,54 @@ | |
| - scapy >= 2.6.1 (already a project dependency) | ||
| """ | ||
|
|
||
| from .mac import NativeMac | ||
| from .deauth import ScapyDeauth, ContinuousDeauth as NativeDeauth | ||
| from .handshake import ScapyHandshake | ||
| from .wps import ScapyWPS, WPSInfo | ||
| from .interface import NativeInterface, InterfaceInfo | ||
| from .pmkid import ScapyPMKID, PMKIDResult, PMKIDCapture | ||
| from .scanner import ChannelHopper, NativeScanner, AccessPoint, Client | ||
| from .beacon import BeaconGenerator, create_fake_ap as create_beacon | ||
| try: | ||
| from .mac import NativeMac | ||
| except BaseException: | ||
| NativeMac = None | ||
|
|
||
| try: | ||
| from .deauth import ScapyDeauth, ContinuousDeauth as NativeDeauth | ||
| except BaseException: | ||
| ScapyDeauth = None | ||
| NativeDeauth = None | ||
|
|
||
| try: | ||
| from .handshake import ScapyHandshake | ||
| except BaseException: | ||
| ScapyHandshake = None | ||
|
|
||
| try: | ||
| from .wps import ScapyWPS, WPSInfo | ||
| except BaseException: | ||
| ScapyWPS = None | ||
| WPSInfo = None | ||
|
|
||
| try: | ||
| from .interface import NativeInterface, InterfaceInfo | ||
| except BaseException: | ||
| NativeInterface = None | ||
| InterfaceInfo = None | ||
|
|
||
| try: | ||
| from .pmkid import ScapyPMKID, PMKIDResult, PMKIDCapture | ||
| except BaseException: | ||
| ScapyPMKID = None | ||
| PMKIDResult = None | ||
| PMKIDCapture = None | ||
|
|
||
| try: | ||
| from .scanner import ChannelHopper, NativeScanner, AccessPoint, Client | ||
| except BaseException: | ||
| ChannelHopper = None | ||
| NativeScanner = None | ||
| AccessPoint = None | ||
| Client = None | ||
|
|
||
| try: | ||
| from .beacon import BeaconGenerator, create_fake_ap as create_beacon | ||
| except BaseException: | ||
| BeaconGenerator = None | ||
| create_beacon = None | ||
|
Comment on lines
+26
to
+73
|
||
|
|
||
| __all__ = [ | ||
| # MAC manipulation | ||
|
|
@@ -80,49 +120,49 @@ def check_native_availability() -> dict: | |
| try: | ||
| from .mac import NativeMac | ||
| status['mac'] = True | ||
| except ImportError: | ||
| except BaseException: | ||
| status['mac'] = False | ||
|
|
||
| try: | ||
| from .deauth import SCAPY_AVAILABLE | ||
| status['deauth'] = SCAPY_AVAILABLE | ||
| except ImportError: | ||
| except BaseException: | ||
| status['deauth'] = False | ||
|
|
||
| try: | ||
| from .handshake import SCAPY_AVAILABLE | ||
| status['handshake'] = SCAPY_AVAILABLE | ||
| except ImportError: | ||
| except BaseException: | ||
| status['handshake'] = False | ||
|
|
||
| try: | ||
| from .wps import SCAPY_AVAILABLE | ||
| status['wps'] = SCAPY_AVAILABLE | ||
| except ImportError: | ||
| except BaseException: | ||
| status['wps'] = False | ||
|
|
||
| try: | ||
| from .interface import NativeInterface | ||
| status['interface'] = True | ||
| except ImportError: | ||
| except BaseException: | ||
| status['interface'] = False | ||
|
|
||
| try: | ||
| from .pmkid import SCAPY_AVAILABLE | ||
| status['pmkid'] = SCAPY_AVAILABLE | ||
| except ImportError: | ||
| except BaseException: | ||
| status['pmkid'] = False | ||
|
|
||
| try: | ||
| from .scanner import SCAPY_AVAILABLE | ||
| status['scanner'] = SCAPY_AVAILABLE | ||
| except ImportError: | ||
| except BaseException: | ||
| status['scanner'] = False | ||
|
|
||
| try: | ||
| from .beacon import SCAPY_AVAILABLE | ||
| status['beacon'] = SCAPY_AVAILABLE | ||
| except ImportError: | ||
| except BaseException: | ||
| status['beacon'] = False | ||
|
Comment on lines
120
to
166
|
||
|
|
||
| return status | ||
|
|
@@ -156,5 +196,5 @@ def print_native_status(): | |
| import scapy | ||
| scapy_version = scapy.VERSION if hasattr(scapy, 'VERSION') else 'unknown' | ||
| print(f"\nScapy Version: {scapy_version}") | ||
| except ImportError: | ||
| except BaseException: | ||
| print("\nScapy: Not Installed") | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,7 +31,7 @@ | |||||||||||||||||||||||
| sendp, sniff, conf as scapy_conf | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
| SCAPY_AVAILABLE = True | ||||||||||||||||||||||||
| except ImportError: | ||||||||||||||||||||||||
| except BaseException: | ||||||||||||||||||||||||
| SCAPY_AVAILABLE = False | ||||||||||||||||||||||||
|
Comment on lines
+34
to
35
|
||||||||||||||||||||||||
| except BaseException: | |
| SCAPY_AVAILABLE = False | |
| SCAPY_IMPORT_ERROR = None | |
| except BaseException as e: | |
| # Do not swallow critical exceptions like KeyboardInterrupt/SystemExit. | |
| if isinstance(e, (KeyboardInterrupt, SystemExit)): | |
| raise | |
| # Scapy failed to import for some other reason; mark as unavailable | |
| # and keep the original exception for potential debugging. | |
| SCAPY_AVAILABLE = False | |
| SCAPY_IMPORT_ERROR = e |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,7 +38,7 @@ | |
| Dot11Elt, Raw, conf as scapy_conf | ||
| ) | ||
| SCAPY_AVAILABLE = True | ||
| except ImportError: | ||
| except BaseException: | ||
| SCAPY_AVAILABLE = False | ||
|
|
||
|
Comment on lines
38
to
43
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,7 +43,7 @@ | |
| sniff, sendp, conf as scapy_conf | ||
| ) | ||
| SCAPY_AVAILABLE = True | ||
| except ImportError: | ||
| except BaseException: | ||
| SCAPY_AVAILABLE = False | ||
|
|
||
|
Comment on lines
43
to
48
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -41,7 +41,7 @@ | |||||||||
| sniff, conf as scapy_conf | ||||||||||
| ) | ||||||||||
| SCAPY_AVAILABLE = True | ||||||||||
| except ImportError: | ||||||||||
| except BaseException: | ||||||||||
|
||||||||||
| except BaseException: | |
| except BaseException as e: | |
| if isinstance(e, (KeyboardInterrupt, SystemExit)): | |
| raise |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import contextlib | ||||||||||||||||||||||||
| import re | ||||||||||||||||||||||||
| import shlex | ||||||||||||||||||||||||
| import time | ||||||||||||||||||||||||
| import signal | ||||||||||||||||||||||||
| import os | ||||||||||||||||||||||||
|
|
@@ -111,7 +112,7 @@ def call(command, cwd=None, shell=False): | |||||||||||||||||||||||
| # Split string commands into list of args for Popen when not using shell mode | ||||||||||||||||||||||||
| if Configuration.verbose > 1: | ||||||||||||||||||||||||
| Color.pe(f'\n {{C}}[?]{{W}} Executing: {{B}}{command}{{W}}') | ||||||||||||||||||||||||
| command = command.split() | ||||||||||||||||||||||||
| command = shlex.split(command) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| command = shlex.split(command) | |
| orig_command = command | |
| try: | |
| command = shlex.split(command) | |
| except ValueError as e: | |
| # Fall back to a naive split if shlex.split fails (e.g., malformed quoting) | |
| log_warning( | |
| f"Failed to parse command with shlex.split(): {e}. " | |
| f"Falling back to naive split for command: {orig_command!r}" | |
| ) | |
| command = orig_command.split() |
Copilot
AI
Mar 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as in Process.call(): shlex.split() can raise ValueError on unmatched quotes. Since this is in the constructor path for many subprocesses, it may be worth handling ValueError explicitly (clear message / fallback) to avoid unexpected crashes from user-supplied command strings.
| command = shlex.split(command) | |
| try: | |
| command = shlex.split(command) | |
| except ValueError as e: | |
| # Provide a clear error message for malformed command strings (e.g., unmatched quotes) | |
| log_error('Process', f'Failed to parse command string {command!r}: {e}', e) | |
| raise |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,7 +13,7 @@ | |||||||||||||||||||||||
| try: | ||||||||||||||||||||||||
| from ..native.scanner import NativeScanner, AccessPoint as NativeAP, is_available as native_scanner_available | ||||||||||||||||||||||||
| NATIVE_SCANNER_AVAILABLE = native_scanner_available() | ||||||||||||||||||||||||
| except ImportError: | ||||||||||||||||||||||||
| except BaseException: | ||||||||||||||||||||||||
| NATIVE_SCANNER_AVAILABLE = False | ||||||||||||||||||||||||
|
Comment on lines
+16
to
17
|
||||||||||||||||||||||||
| except BaseException: | |
| NATIVE_SCANNER_AVAILABLE = False | |
| except BaseException as e: | |
| # Do not swallow interrupts/exits during startup | |
| if isinstance(e, (KeyboardInterrupt, SystemExit)): | |
| raise | |
| # Any other error means the native scanner is not available | |
| NATIVE_SCANNER_AVAILABLE = False | |
| # Optionally log the underlying import error when in verbose mode | |
| if Configuration.verbose > 0: | |
| Color.pexception(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Catching
BaseExceptionhere will also swallowKeyboardInterrupt/SystemExit, which can lead to surprising behavior at import time. IfBaseExceptionis needed to handle specific native import crashes, consider re-raising interrupt/exit exceptions and/or logging the underlying error when verbose so native PMKID availability doesn't silently flip toFalseon unexpected failures.