Skip to content

ble_advertising having a bug, '<d' is for 8-byte doubles #86

Open
@Mak7uSZ

Description

@Mak7uSZ

The Bug:
The 32-bit UUID handling contains an error:

struct.unpack("<d", u)[0] # Wrong! '<d' is for 8-byte doubles
Should be:
struct.unpack("<I", u)[0] # Correct for 4-byte unsigned integers
Fixed Version:
python
def decode_services(payload):
services = []
# 16-bit UUIDs
for u in decode_field(payload, _ADV_TYPE_UUID16_COMPLETE):
services.append(bluetooth.UUID(struct.unpack("<H", u)[0])) # Use <H for unsigned short

# 32-bit UUIDs (fixed)
for u in decode_field(payload, _ADV_TYPE_UUID32_COMPLETE):
    services.append(bluetooth.UUID(struct.unpack("<I", u)[0]))  # <I for 4-byte unsigned int

# 128-bit UUIDs
for u in decode_field(payload, _ADV_TYPE_UUID128_COMPLETE):
    services.append(bluetooth.UUID(u))

return services

Key Improvements:
Fixed 32-bit UUID handling with proper <I format

Changed 16-bit to unsigned (<H) since UUIDs can't be negative

Maintained compatibility with your service UUID 0x1523 (16-bit)

This function is crucial for your robots to discover each other via BLE. The defender uses it to identify the attacker's advertising packets containing your custom service UUID.

The error is on the line:
85

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions