Fix Scapy 2.5+ and Python 3.10+ compatibility#61
Conversation
Scapy 2.5.0 removed L2Socket, attach_filter, and get_if_raw_hwaddr from its wildcard export and moved scapy.arch.common.get_if_raw_hwaddr; add explicit imports so the tool works on current Kali/Debian installs. - libwifi/wifi.py: import L2Socket and attach_filter from scapy.arch; wrap _rt_txflags mutation in try/except for forward compatibility; fix get_ccmp_payload str->bytes (Python 3 correctness); fix create_msdu_subframe padding initialised as str instead of bytes; use raw strings for regex patterns (SyntaxWarning in Python 3.12+) - fraginternals.py: fallback import for get_if_raw_hwaddr; add 0.5s sleep + clear error message after virtual monitor interface creation to mitigate mt76 null-pointer dereference (issue vanhoefm#60); raw string for regex - requirements.txt: replace 2020-era exact pins with >= minimums, drop Python 3.7-only packages (importlib-metadata, zipp, py), require scapy>=2.5.0 - pysetup.sh: guard BPF sed patch so it doesn't fail when file absent - fragattack.py: suppress DeprecationWarnings from scapy.layers.ipsec Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…w_hwaddr) Three more Scapy APIs removed in 2.5–2.7 that cause ImportError or AttributeError at startup on current Kali installs: - scapy.contrib.wpa_eapol.WPA_key removed: fall back to scapy.layers.eap.EAPOL_KEY and reconstruct the key_info integer from its individual bit fields via _eapol_key_info() - scapy.arch.get_if_index removed: monkey-patch it back onto scapy.arch using SIOCGIFINDEX ioctl so configure_interfaces() can check whether the virtual monitor interface already exists - scapy.arch.get_if_raw_hwaddr removed: fall back to SIOCGIFHWADDR ioctl in both fraginternals.py and libwifi/wifi.py Tested: test-injection.py passes all checks on ath9k_htc with Scapy 2.7 and Python 3.13; fragattack.py --help and startup run cleanly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
OSSL_PROVIDER_try_load() is used under #if OPENSSL_VERSION_NUMBER >= 0x30000000L but <openssl/provider.h> was never included, causing an implicit-function-declaration error on OpenSSL 3.0+ (tested on 3.6.3). Add the include under the same guard. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
EapolAmsduTest.__init__ enforces exactly 1 inject action but fragattack.py was passing 2 by default, causing an immediate quit(1) on every invocation of eapol-amsdu and eapol-amsdu-bad without custom --actions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks for taking the time to work towards updated Python compatibility! I've found that in the past, the behaviour of Scapy can subtly change between versions, so the code doesn't crash but might no longer send the same frames. For this reason, I'm hesitant to move to a different Scapy version, and also a new Python version, without quite detailed testing to ensure everything still works the same. To solve some of the Python dependencies, in the short term, switching to uv is best (instead of the virtualenv currently). That should allow the use of the older Python and Scapy versions that were extensively tested. Long term, a new branch can be created to move to a new Python version, but I doubt I will have the time to maintain that. Code issues and updates different from updating the Scapy and Python versions are something I can more easily adopt in the main branch, e.g., the 0.5s delay to prevent one of the crashes. |
|
Okay, that makes complete sense. Let's begin with just fixing the 0.5s delay. I would gladly contribute to a new branch for the Python and Scapy fixes if you decide to set one up. As a long-time user of your tool, I've had to rely on the live OS method rather than a generic clone, so I'd love to help get those updates sorted out! |
Fixes #59. Addresses driver crash in #60.
Changes
Scapy 2.5+ import fixes (libwifi/wifi.py, fraginternals.py)
L2Socketandattach_filterno longer inscapy.allwildcard — explicit import fromscapy.archscapy.contrib.wpa_eapol.WPA_keyremoved — fall back toscapy.layers.eap.EAPOL_KEY; reconstructkey_infofrom individual bit fieldsscapy.arch.get_if_raw_hwaddrremoved — SIOCGIFHWADDR ioctl fallbackscapy.arch.get_if_indexremoved — SIOCGIFINDEX ioctl monkey-patched backPython 3.12+ fixes
\d,\wSyntaxWarning)get_ccmp_payload:str(bytes)→bytes()(Python 2 leftover)create_msdu_subframe: padding""→b""Issue #60 mitigation (fraginternals.py)
--injecthint if creation failsrequirements.txt / pysetup.sh
>=, requirescapy>=2.5.0Tested:
test-injection.pypasses all checks on ath9k_htc with Scapy 2.7 + Python 3.13.