Skip to main content

Scapy helpers to communicate with Bluetooth controllers

Project description

Scapy UsbBluetooth

Build PyPI scapy-usbbluetooth License: GPL v3

This package contains code to allow Scapy sockets to communicate with Bluetooth controllers using UsbBluetooth.

Installation

Just use pip :)

pip install scapy-usbbluetooth

Usage

See the examples folder for sample code.

A short illustrative sample usage can be as follows:

import usbbluetooth
from scapy_usbbluetooth import UsbBluetoothSocket
from scapy.layers.bluetooth import HCI_Hdr, HCI_Command_Hdr, HCI_Cmd_Reset


# Get a list of all the available devices
devices = usbbluetooth.list_devices()
for dev in devices:
    print(dev)

# Open a socket using a device
socket = UsbBluetoothSocket(devices[0])

# Create a reset packet
pkt = HCI_Hdr() / HCI_Command_Hdr() / HCI_Cmd_Reset()

# Send a packet to the controller and await a response
response = socket.sr1(pkt)
response.show()

Plaform quirks

Windows

In Windows you may have to install WinUSB driver in your device using Zadig. Otherwise, UsbBluetooth will detect your device but it may not be able to take control of your device.

Linux

Your Linux user must have permissions to access USB hardware. Here are several options to ensure access:

  • Run as root: Execute the application with elevated privileges using sudo. Note that this may not be ideal for security reasons.

  • Add user to a group: Add your user to the plugdev, usb or uucp group (depending on your distribution). Remeber to reboot or log out and log back in for the changes to take effect. For example:

    sudo usermod -a -G plugdev $USER
    
  • Create a udev rule: Create a custom udev rule to automatically set permissions for USB Bluetooth devices. Create a file like /etc/udev/rules.d/99-usbbluetooth.rules with content similar to:

    SUBSYSTEM=="usb", ATTR{idVendor}=="your_vendor_id", ATTR{idProduct}=="your_product_id", MODE="0666"
    

    Replace your_vendor_id and your_product_id with the actual vendor and product IDs of your device (you can find these using lsusb). Then reload udev rules with sudo udevadm control --reload-rules && sudo udevadm trigger.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scapy_usbbluetooth-0.1.0.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scapy_usbbluetooth-0.1.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file scapy_usbbluetooth-0.1.0.tar.gz.

File metadata

  • Download URL: scapy_usbbluetooth-0.1.0.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for scapy_usbbluetooth-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c4aa6ba1b4e7aba94f7c6953b06c2019dc3608c7cb54549d1aa17966b8d1c71f
MD5 0f8b355adc761b3dc91a04db2a353c98
BLAKE2b-256 472bafe2afca3414a0496495e3160125cf9915e9fe66e52cb7ada9dab2cf04d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for scapy_usbbluetooth-0.1.0.tar.gz:

Publisher: build.yml on usbbluetooth/scapy-usbbluetooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scapy_usbbluetooth-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for scapy_usbbluetooth-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 460cb8921d6931cbc5572db44fb5e3269582808dfae9c992160a465f0b24a7ca
MD5 4a9fa0abb0b7a93de0586008d4cb37fc
BLAKE2b-256 b415e78c7545866940e59a74e0a6b83455777783cf51d5b7b5c5c43749e5460e

See more details on using hashes here.

Provenance

The following attestation bundles were made for scapy_usbbluetooth-0.1.0-py3-none-any.whl:

Publisher: build.yml on usbbluetooth/scapy-usbbluetooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page