mirror of
https://github.com/smittix/intercept.git
synced 2026-04-24 22:59:59 -07:00
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:
@@ -305,8 +305,18 @@ class DBusScanner:
|
||||
if mfr_data:
|
||||
for mid, mdata in mfr_data.items():
|
||||
manufacturer_id = int(mid)
|
||||
if isinstance(mdata, dbus.Array):
|
||||
manufacturer_data = bytes(mdata)
|
||||
# Handle various DBus data types safely
|
||||
try:
|
||||
if isinstance(mdata, (bytes, bytearray)):
|
||||
manufacturer_data = bytes(mdata)
|
||||
elif isinstance(mdata, dbus.Array):
|
||||
manufacturer_data = bytes(mdata)
|
||||
elif isinstance(mdata, (list, tuple)):
|
||||
manufacturer_data = bytes(mdata)
|
||||
elif isinstance(mdata, str):
|
||||
manufacturer_data = bytes.fromhex(mdata)
|
||||
except (TypeError, ValueError) as e:
|
||||
logger.debug(f"Could not convert manufacturer data: {e}")
|
||||
break
|
||||
|
||||
# Extract service UUIDs
|
||||
@@ -319,8 +329,17 @@ class DBusScanner:
|
||||
service_data = {}
|
||||
if 'ServiceData' in props:
|
||||
for uuid, data in props['ServiceData'].items():
|
||||
if isinstance(data, dbus.Array):
|
||||
service_data[str(uuid)] = bytes(data)
|
||||
try:
|
||||
if isinstance(data, (bytes, bytearray)):
|
||||
service_data[str(uuid)] = bytes(data)
|
||||
elif isinstance(data, dbus.Array):
|
||||
service_data[str(uuid)] = bytes(data)
|
||||
elif isinstance(data, (list, tuple)):
|
||||
service_data[str(uuid)] = bytes(data)
|
||||
elif isinstance(data, str):
|
||||
service_data[str(uuid)] = bytes.fromhex(data)
|
||||
except (TypeError, ValueError) as e:
|
||||
logger.debug(f"Could not convert service data for {uuid}: {e}")
|
||||
|
||||
# Extract Class of Device (Classic BT)
|
||||
class_of_device = None
|
||||
|
||||
Reference in New Issue
Block a user