Scapy helpers to communicate with Bluetooth controllers
Project description
Scapy UsbBluetooth
This package contains code to allow Scapy sockets to communicate with Bluetooth controllers using UsbBluetooth for Python.
For general documentation about the project, please visit usbbluetooth.github.io.
For a barebones Python version of this library, check out UsbBluetooth for Python.
For other programming languages you may visit UsbBluetooth for C or UsbBluetooth for C#.
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,usboruucpgroup (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.ruleswith content similar to:SUBSYSTEM=="usb", ATTR{idVendor}=="your_vendor_id", ATTR{idProduct}=="your_product_id", MODE="0666"Replace
your_vendor_idandyour_product_idwith the actual vendor and product IDs of your device (you can find these usinglsusb). Then reload udev rules withsudo 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scapy_usbbluetooth-0.1.1.tar.gz.
File metadata
- Download URL: scapy_usbbluetooth-0.1.1.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63f8789220aa06ea00d5021fdcd80f7fe7c4293eebcc9db34ecefbb323ada2f9
|
|
| MD5 |
2851517246aa9c6f5b268b334583813a
|
|
| BLAKE2b-256 |
9cfe9ae0464ed9ec58cc342ea62469a488396145019182e72e9a2e632c801b13
|
Provenance
The following attestation bundles were made for scapy_usbbluetooth-0.1.1.tar.gz:
Publisher:
build.yml on usbbluetooth/scapy-usbbluetooth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scapy_usbbluetooth-0.1.1.tar.gz -
Subject digest:
63f8789220aa06ea00d5021fdcd80f7fe7c4293eebcc9db34ecefbb323ada2f9 - Sigstore transparency entry: 767022795
- Sigstore integration time:
-
Permalink:
usbbluetooth/scapy-usbbluetooth@563a0f6c5783bd41e264cabf8df5b60e80842e86 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/usbbluetooth
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@563a0f6c5783bd41e264cabf8df5b60e80842e86 -
Trigger Event:
push
-
Statement type:
File details
Details for the file scapy_usbbluetooth-0.1.1-py3-none-any.whl.
File metadata
- Download URL: scapy_usbbluetooth-0.1.1-py3-none-any.whl
- Upload date:
- Size: 16.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc9498a4234b19cb5f857bee334a9e5abb540c7055ef0916e99b3bc49e3cc927
|
|
| MD5 |
d2b9f2265aaab12427ad2a13552f046d
|
|
| BLAKE2b-256 |
76a61cc6ccd22821165097c6064609c459f7872f620f8b93a7a8adb02ccb2b7e
|
Provenance
The following attestation bundles were made for scapy_usbbluetooth-0.1.1-py3-none-any.whl:
Publisher:
build.yml on usbbluetooth/scapy-usbbluetooth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scapy_usbbluetooth-0.1.1-py3-none-any.whl -
Subject digest:
fc9498a4234b19cb5f857bee334a9e5abb540c7055ef0916e99b3bc49e3cc927 - Sigstore transparency entry: 767022804
- Sigstore integration time:
-
Permalink:
usbbluetooth/scapy-usbbluetooth@563a0f6c5783bd41e264cabf8df5b60e80842e86 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/usbbluetooth
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@563a0f6c5783bd41e264cabf8df5b60e80842e86 -
Trigger Event:
push
-
Statement type: