|
| 1 | +#!/usr/bin/env python3 |
| 2 | + |
| 3 | +import sys |
| 4 | +sys.path.insert(0, '.') |
| 5 | + |
| 6 | +from wifite.tools.airmon import Airmon |
| 7 | + |
| 8 | +# Test with the exact current output |
| 9 | +test_output = """ |
| 10 | +Found 6 processes that could cause trouble. |
| 11 | +Kill them using 'airmon-ng check kill' before putting |
| 12 | +the card in monitor mode, they will interfere by changing channels |
| 13 | +and sometimes putting the interface back in managed mode |
| 14 | +
|
| 15 | + PID Name |
| 16 | + 7044 avahi-daemon |
| 17 | + 7105 avahi-daemon |
| 18 | + 7183 wpa_supplicant |
| 19 | + 25765 NetworkManager |
| 20 | +2503235 dhclient |
| 21 | +2523490 dhclient |
| 22 | +
|
| 23 | +PHY Interface Driver Chipset |
| 24 | +
|
| 25 | +phy1 wlp4s0 iwlwifi Intel Corporation Wi-Fi 6E(802.11ax) AX210/AX1675* 2x2 [Typhoon Peak] (rev 1a) |
| 26 | +phy0 wlxd037456283c3 rtl8xxxu TP-Link TL-WN821N v5/v6 [RTL8192EU] |
| 27 | + (mac80211 monitor mode already enabled for [phy0]wlxd037456283c3 on [phy0]10) |
| 28 | +""" |
| 29 | + |
| 30 | +print("Testing exact airmon-ng output...") |
| 31 | +result = Airmon._parse_airmon_start(test_output) |
| 32 | +print(f"Result: '{result}'") |
| 33 | + |
| 34 | +# Let's debug the regex matching |
| 35 | +import re |
| 36 | + |
| 37 | +enabled_on_re = re.compile(r'.*\(mac80211 monitor mode (?:(?:vif )?enabled|already enabled) (?:for [^ ]+ )?on (?:\[\w+])?([a-zA-Z]\w+)\)?.*') |
| 38 | +enabled_for_re = re.compile(r'.*\(mac80211 monitor mode (?:(?:vif )?enabled|already enabled) for (?:\[\w+])?(\w+).*on (?:\[\w+])?\d+\)?.*') |
| 39 | + |
| 40 | +lines = test_output.split('\n') |
| 41 | +for i, line in enumerate(lines): |
| 42 | + if 'mac80211 monitor mode' in line: |
| 43 | + print(f"\nLine {i}: {repr(line)}") |
| 44 | + |
| 45 | + match1 = enabled_on_re.match(line) |
| 46 | + if match1: |
| 47 | + print(f" enabled_on_re matched: '{match1.group(1)}'") |
| 48 | + else: |
| 49 | + print(" enabled_on_re: no match") |
| 50 | + |
| 51 | + match2 = enabled_for_re.match(line) |
| 52 | + if match2: |
| 53 | + print(f" enabled_for_re matched: '{match2.group(1)}'") |
| 54 | + else: |
| 55 | + print(" enabled_for_re: no match") |
| 56 | + |
| 57 | + # Check the legacy fallback |
| 58 | + if "monitor mode enabled" in line: |
| 59 | + print(f" legacy fallback would return: '{line.split()[-1]}'") |
| 60 | + else: |
| 61 | + print(" legacy fallback: no match") |
0 commit comments