Pentesting BLE - Bluetooth Low Energy

Support HackTricks

介绍

自Bluetooth 4.0规范以来,BLE仅使用40个频道,覆盖2400到2483.5 MHz的范围。相比之下,传统蓝牙在同一范围内使用79个频道。

BLE设备通过发送广告数据包信标)进行通信,这些数据包向其他附近设备广播BLE设备的存在。这些信标有时也会发送数据

监听设备,也称为中央设备,可以通过向广告设备发送特定的扫描请求来响应广告数据包。该扫描的响应使用与广告数据包相同的结构,并包含无法在初始广告请求中容纳的附加信息,例如完整的设备名称。

前导字节用于同步频率,而四字节访问地址是连接标识符,在多个设备尝试在同一频道上建立连接的场景中使用。接下来,协议数据单元(PDU)包含广告数据。PDU有几种类型;最常用的是ADV_NONCONN_IND和ADV_IND。如果设备不接受连接,则使用ADV_NONCONN_IND PDU类型,仅在广告数据包中传输数据。如果设备允许连接,并且在建立连接停止发送广告数据包,则使用ADV_IND

GATT

通用属性配置文件(GATT)定义了设备应如何格式化和传输数据。当您分析BLE设备的攻击面时,您通常会将注意力集中在GATT(或GATTs)上,因为这是设备功能被触发以及数据被存储、分组和修改的方式。GATT以表格形式列出设备的特性、描述符和服务,值为16位或32位。特性在中央设备和外设之间发送的数据值。这些特性可以具有描述符,以提供有关它们的附加信息。如果特性与执行特定操作相关,则特性通常会在服务分组

枚举

hciconfig #Check config, check if UP or DOWN
# If DOWN try:
sudo modprobe -c bluetooth
sudo hciconfig hci0 down && sudo hciconfig hci0 up

# Spoof MAC
spooftooph -i hci0 -a 11:22:33:44:55:66

GATTool

GATTool 允许与另一个设备 建立 连接,列出该设备的 特征,并读取和写入其属性。 GATTTool 可以使用 -I 选项启动交互式 shell:

gatttool -i hci0 -I
[ ][LE]> connect 24:62:AB:B1:A8:3E Attempting to connect to A4:CF:12:6C:B3:76 Connection successful
[A4:CF:12:6C:B3:76][LE]> characteristics
handle: 0x0002, char properties: 0x20, char value handle:
0x0003, uuid: 00002a05-0000-1000-8000-00805f9b34fb
handle: 0x0015, char properties: 0x02, char value handle:
0x0016, uuid: 00002a00-0000-1000-8000-00805f9b34fb
[...]

# Write data
gatttool -i <Bluetooth adapter interface> -b <MAC address of device> --char-write-req <characteristic handle> -n <value>
gatttool -b a4:cf:12:6c:b3:76 --char-write-req -a 0x002e -n $(echo -n "04dc54d9053b4307680a"|xxd -ps)

# Read data
gatttool -i <Bluetooth adapter interface> -b <MAC address of device> --char-read -a 0x16

# Read connecting with an authenticated encrypted connection
gatttool --sec-level=high -b a4:cf:12:6c:b3:76 --char-read -a 0x002c

Bettercap

# Start listening for beacons
sudo bettercap --eval "ble.recon on"
# Wait some time
>> ble.show # Show discovered devices
>> ble.enum <mac addr> # This will show the service, characteristics and properties supported

# Write data in a characteristic
>> ble.write <MAC ADDR> <UUID> <HEX DATA>
>> ble.write <mac address of device> ff06 68656c6c6f # Write "hello" in ff06
支持 HackTricks

Last updated