Fix regex parsing of airmon-ng monitor interface name

The previous regex incorrectly captured "for" from airmon-ng output
like "monitor mode enabled for [phy0]wlp3s0 on wlp3s0mon". Now uses
a more specific pattern that looks for "on <interface>mon" first,
with fallback to any word ending in "mon".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
James Smith
2025-12-21 11:01:07 +00:00
parent e5eb95231c
commit 902575b583

View File

@@ -4856,9 +4856,13 @@ def toggle_monitor_mode():
# Parse output to find monitor interface name
output = result.stdout + result.stderr
# Common patterns: wlan0mon, wlan0, mon0
# Common patterns: wlan0mon, wlp3s0mon, etc.
import re
match = re.search(r'monitor mode.*?enabled.*?(\w+mon|\w+)', output, re.IGNORECASE)
# Look for "on <interface>mon" pattern first (most reliable)
match = re.search(r'\bon\s+(\w+mon)\b', output, re.IGNORECASE)
if not match:
# Fallback: look for interface name ending in 'mon'
match = re.search(r'\b(\w+mon)\b', output)
if match:
wifi_monitor_interface = match.group(1)
else: