Fix Bluetooth bytes conversion and WiFi monitor mode detection

- Fix "cannot convert 'str' object to bytes" error in BLE identity engine
  by adding robust _convert_to_bytes() helper that handles bytes, hex
  strings, bytearrays, and arrays
- Improve DBus scanner to safely handle various data types for
  manufacturer_data and service_data with proper error handling
- Add monitor mode interface detection in WiFi scanner to provide clear
  error message when quick scan is attempted on monitor mode interface

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Smittix
2026-01-21 23:25:22 +00:00
parent 54a47b03c2
commit f01502ff32
3 changed files with 90 additions and 6 deletions

View File

@@ -265,6 +265,36 @@ class UnifiedWiFiScanner:
pass
return False
def _is_monitor_mode_interface(self, interface: str) -> bool:
"""
Check if interface is currently in monitor mode.
Returns True if:
- Interface name ends with 'mon' (common convention)
- iw reports type as 'monitor'
"""
# Quick check by name convention
if interface.endswith('mon'):
return True
# Check actual mode via iw
if shutil.which('iw'):
try:
result = subprocess.run(
['iw', interface, 'info'],
capture_output=True,
text=True,
timeout=TOOL_TIMEOUT_DETECT,
)
if result.returncode == 0:
# Look for "type monitor" in output
if re.search(r'type\s+monitor', result.stdout, re.IGNORECASE):
return True
except Exception:
pass
return False
# =========================================================================
# Quick Scan
# =========================================================================
@@ -299,6 +329,17 @@ class UnifiedWiFiScanner:
result.interface = iface
# Check if interface is in monitor mode (can't use quick scan tools on monitor interfaces)
if self._is_monitor_mode_interface(iface):
result.error = (
f"Interface '{iface}' appears to be in monitor mode. "
"Quick scan requires a managed mode interface. "
"Either use a different interface, disable monitor mode, or use deep_scan() with airodump-ng."
)
result.is_complete = True
result.warnings.append("Monitor mode interfaces don't support standard WiFi scanning")
return result
# Select and run parser based on platform/tools
# Try multiple tools with fallback on Linux
observations = []