BLE Hacking:使用Ubertooth one扫描嗅探低功耗蓝牙
0×00 前言
低功耗蓝牙(Low Energy; LE),又视为Bluetooth Smart或蓝牙核心规格4.0版本。其特点具备节能、便于采用,是蓝牙技术专为物联网(Internet of Things; IOT)开发的技术版本。
类似文章推荐:永不消逝的电波(三):低功耗蓝牙(BLE)入门之如何调戏别人的小米手环。
BLE主打功能是快速搜索,快速连接,超低功耗保持连接和传输数据,弱点是数据传输速率低,由于BLE的低功耗特点,因此普遍用于穿戴设备。
我们比较熟悉的网络有 Zigbee,WIFI、Bluetooth(传统蓝牙),三者之间的关系如下:
不同的无线数据传输协议在数据传输速率利传输距离有各自的使用范围。Zigbee、蓝牙以及 WIFI 标准都是工作在 2.4GHz 频段的无线通信标准。
传统蓝牙数据传输速率小于 3Mbps,典型数据传输距离为 2-10m,蓝牙技术的典型应用是在两部手机之间进行小量数据的传输。
WIFI 最高数据传输速率可达 50Mbps,典型数据传输距离在 30-100m,WIFI 技术提供了一种 Intemet 的无线接入技术。
0×01 蓝牙与低功耗蓝牙
1.1 标准
蓝牙无线技术是使用范围最广泛的全球短距离无线标准之一,全新的蓝牙 4.0 版本将传统蓝牙,高速蓝牙和低功耗蓝牙技术三种蓝牙技术合而为一。它集成了蓝牙技术在无线连接上的固有优势,同时增加了高速蓝牙和低功耗蓝牙的特点,这三个规格可以组合使用,也可以单独使用,低功耗蓝牙即 ble 是蓝牙 4.0 的核心规范,该技术最大特点是拥有超低的运行功耗和待机功耗,蓝牙低功耗设备使用一粒纽扣电池可以连续工作数年之久,可应用与对成本和功耗都有严格要求的无线方案,而且随之智能机的发展将有着更加广泛的领域。
BLE分为三部分Service、Characteristic、Descriptor,这三部分都由UUID作为唯一标示符。一个蓝牙4.0的终端可以包含多个Service,一个Service可以包含多个Characteristic,一个Characteristic包含一个Value和多个Descriptor,一个Descriptor包含一个Value。
BLE 规范中定义了 GAP(Generic Access Profile)和 GATT(Generic Attribute)两个基本配置文件。
GAP 层负责设备访问模式和进程,包括设备发现,建立连接,终止连接。初始化安全特征和设备配置。
GATT 层用于已连接的蓝牙设备之间的数据通信。
1.2 BLE特点&优势
1.2.1高可靠性
对于无线通信而言,由于电磁波在传输过程中容易受很多因素的干扰,例如,障碍物的阻挡、天气状况等,因此,无线通信系统在数据传输过程中具有内在的不可靠性。蓝牙技术联盟 SIG 在指定蓝牙 4.0 规范时已经考虑到了这种数据传输过程中的内在的不确定性,在射频,基带协议,链路管理协议中采用可靠性措施,包括:差错检测和矫正,进行数据编解码,数据降噪等,极大地提高了蓝牙无线数据传输的可靠性,另外,使用自适应调频技术,能最大程度地减少和其他 2.4G 无线电波的串扰。
1.2.2 低成本、低功耗
低功耗蓝牙支持两种部署方式:双模式和单模式,一般智能机上采用双模式,外设一般采用 BLE 单模。
BLE 技术可以应用于 8-bit MCU, 目前 TI 公司推出的兼容 BluetoothLE 协议的 SoC芯片 CC254X 每片价格在 7.6 元左右, 外接几个阻容器件构成的滤波电路和 PCB 天线即可实现网络节点的构建。Nodic的NRF51822也不过才10元人民币。
低功耗设计:蓝牙 4.0 版本强化了蓝牙在数据传输上的低功耗性能,功耗较传统蓝牙降低了 90%。
传统蓝牙设备的待机耗电量一直是其缺陷之一,这与传统蓝牙技术采用16至32个频道进行广播有很大关系,而低功耗蓝牙仅适用 3个广播通道,且每次广播时射频的开启时间也有传统的 22.5ms 减少到 0.6~1.2ms,这两个协议规范的改变,大幅降低了因为广播数据导致的待机功耗。
低功耗蓝牙设计用深度睡眠状态来替换传统蓝牙的空闲状态,在深度睡眠状态下,主机 Host 长时间处于超低的负载循环 Duty Cycle 状态,只在需要运作时由控制器来启动,由于主机较控制器消耗的能源更多,因此这样的设计也节省了更多的能源。
1.2.3 快速启动、瞬间连接
此前蓝牙版本的启动速度非常缓慢,2.1 版本的蓝牙启动连接需要 6s 时间,而蓝牙4.0 版本仅需要 3ms 即可完成,几乎是瞬间连接。
1.2.4 传输距离极大提供
传统蓝牙传输距离一般 2-10m,而蓝牙 4.0 的有效传输距离可以达到 60~100m,传输距离提升了 10 倍,极大开拓了蓝牙技术的应用前景。
1.2.5 高安全性
为了保证数据传输的安全性,使用 AES-128 CCM 加密算法进行数据包加密认证,对于初学阶段,安全性问题可以暂时不考虑。
1.3 协议栈
协议栈内容请参考:Understanding Bluetooth Advertising Packets一文。
中文版:http://blog.csdn.net/ooakk/article/details/7302425
1.4 通信信道
BLE 工作在 ISM 频带,定义了两个频段,2.4GHz 频段和 896/915MHz 频带。在IEEE802.15.4 中共规定了 27 个信道:
在 2.4GHz 频段,共有 16 个信道,信道通信速率为 250kbps:
在 915MHz 频段,共有 10 个信道,信道通信速率为 40kbps:
在 868MHz 频段,有 1 个信道,信道通信速率为 20kbpS。
BLE 工作在 2.4GHz 频段,仅适用 3 个广播通道,适用所有蓝牙规范版本通用的自适应调频技术。
BlueTooth 有79个射频信道,按0-78排序,并于2402 MHz开始,以1 MHz分隔:
- channel : 2.402000000 Ghz
- channel : 2.403000000 Ghz
- …
- channel : 2.480000000 Ghz
BTLE有40个频道(也称为信道),按37在第一个,后面由0-36,然后第39信道(那么38呢 :) )第38信道位于10和11之间:
- channel : 2.402000000 Ghz
- channel : 2.404000000 Ghz
- channel : 2.406000000 Ghz
- channel : 2.408000000 Ghz
- channel : 2.410000000 Ghz
- channel : 2.412000000 Ghz
- channel : 2.414000000 Ghz
- channel : 2.416000000 Ghz
- channel : 2.418000000 Ghz
- channel : 2.420000000 Ghz
- channel : 2.422000000 Ghz
- channel : 2.424000000 Ghz
- channel : 2.426000000 Ghz
- channel : 2.428000000 Ghz
- channel : 2.430000000 Ghz
- channel : 2.432000000 Ghz
- channel : 2.434000000 Ghz
- channel : 2.436000000 Ghz
- channel : 2.438000000 Ghz
- channel : 2.440000000 Ghz
- channel : 2.442000000 Ghz
- channel : 2.444000000 Ghz
- channel : 2.446000000 Ghz
- channel : 2.448000000 Ghz
- channel : 2.450000000 Ghz
- channel : 2.452000000 Ghz
- channel : 2.454000000 Ghz
- channel : 2.456000000 Ghz
- channel : 2.458000000 Ghz
- channel : 2.460000000 Ghz
- channel : 2.462000000 Ghz
- channel : 2.464000000 Ghz
- channel : 2.466000000 Ghz
- channel : 2.468000000 Ghz
- channel : 2.470000000 Ghz
- channel : 2.472000000 Ghz
- channel : 2.474000000 Ghz
- channel : 2.476000000 Ghz
- channel : 2.478000000 Ghz
- channel : 2.480000000 Ghz
40个频道中:37、38、39为广播信道,另外37个频道用于数据的传输:
使用德州仪器(TI)CC2540蓝牙低功耗模块配合官方的SmartRF协议软件包监听器:PACKET-SNIFFER,可对三个蓝牙广播信道进行嗅探。
使用方法可参考:Ti.com.cn/packet-sniffer 这种嗅探方案优点是廉价,不足是只能嗅探到广播信道的数据包,无法捕获连接完成后也就是设备通信过程中的数据包:
基于HackRF嗅探蓝牙数据包实际上也是可行的:
其方法参考jxj童鞋的BTLE packet sniffer based on HACKRF (function and performance similar to TI’s packet sniffer)
HackRF.NET 中文版:基于HACKRF的低功耗蓝牙(BTLE)packet sniffer/scanner
0×02 环境搭建:
我们说到上面的方案只能嗅探到广播信道的数据包,无法捕获通信过程中的蓝牙数据包,接下来我们将使用Ubertooth One来弥补上面方案的缺陷。
2.1安装lib库
- apt-get install python-software-properties
- add-apt-repository ppa:pyside
- apt-get update
- apt-get install libnl-dev libusb-1.0--dev pyside-tools
2.2 安装libbtbb
- wget https://github.com/greatscottgadgets/libbtbb/archive/2015-09-R2.tar.gz -O libbtbb-2015-09-R2.tar.gz
- tar xf libbtbb---R2.tar.gz
- cd libbtbb---R2
- mkdir build
- cd build
- cmake ..
- make
- sudo make install
2.3 安装ubertooth
- wget https://github.com/greatscottgadgets/ubertooth/releases/download/2015-09-R2/ubertooth-2015-09-R2.tar.xz -O ubertooth-2015-09-R2.tar.xz
- tar xf ubertooth---R2.tar.xz
- cd ubertooth---R2/host
- mkdir build
- cd build
- cmake ..
- make
- sudo make install
- sudo ldconfig
2.4 安装wireshark
- sudo apt-get install checkinstall
- wget https://www.wireshark.org/download/src/wireshark-2.0.3.tar.bz2
- tar -xvf wireshark-2.0..tar.bz2
- cd wireshark-2.0.
- ./configure
- make
- make install
2.5 安装kismet
- wget https://kismetwireless.net/code/kismet-2013-03-R1b.tar.xz
- tar xf kismet---R1b.tar.xz
- cd kismet---R1b
- ln -s ../ubertooth---R2/host/kismet/plugin-ubertooth .
- ./configure
- make && make plugins
- sudo make suidinstall
- sudo make plugins-install
2.6 安装BLE解密工具crackle (开源项目地址)
- git clone https://github.com/mikeryan/crackle.git
- cd crackle
- make
- make install
找到kismet的配置文件kismet.conf ,把”pcapbtbb”加入到kismet.conf的logtypes= 里边
0×03 嗅探扫描
3.1 spectool
spectool_curses
spectool_gtk 扫描附近信号并在频谱上显示:
spectool_raw RAW中文解释是“原材料”或“未经处理的东西”,这里猜测是显示设备捕获到的未经处理的信号数据:
spectool_net 将Ubertooth One作为一台“硬件服务器”,并监听TCP:30569端口,局域网内任何可以跟主机建立通信的PC可通过Ubertoothe主机IP+30569共享设备。连接方式:在另外一台主机终端上执行:spectool_gtk —>选择Open Network Device —>输入ip、端口。
3.2 hcitool
- root@0xroot:~# hcitool --help
- hcitool - HCI Tool ver 4.99
- Usage:
- hcitool [options] <command> [command parameters]
- Options:
- --help Display help
- -i dev HCI device
- Commands:
- dev Display local devices
- inq Inquire remote devices
- scan Scan for remote devices
- name Get name from remote device
- info Get information from remote device
- spinq Start periodic inquiry
- epinq Exit periodic inquiry
- cmd Submit arbitrary HCI commands
- con Display active connections
- cc Create connection to remote device
- dc Disconnect from remote device
- sr Switch master/slave role
- cpt Change connection packet type
- rssi Display connection RSSI
- lq Display link quality
- tpl Display transmit power level
- afh Display AFH channel map
- lp Set/display link policy settings
- lst Set/display link supervision timeout
- auth Request authentication
- enc Set connection encryption
- key Change connection link key
- clkoff Read clock offset
- clock Read local or remote clock
- lescan Start LE scan
- lewladd Add device to LE White List
- lewlrm Remove device from LE White List
- lewlsz Read size of LE White List
- lewlclr Clear LE White list
- lecc Create a LE Connection
- ledc Disconnect a LE Connection
- lecup LE Connection Update
hcitool scan :扫描附近蓝牙设备
hcitool lescan :扫描附近低功耗蓝牙设备
3.3 gatttool
- root@0xroot:~# gatttool -h
- Usage:
- gatttool [OPTION...]
- Help Options:
- -h, --help Show help options
- --help-all Show all help options
- --help-gatt Show all GATT commands
- --help-params Show all Primary Services/Characteristics arguments
- --help-char-read-write Show all Characteristics Value/Descriptor Read/Write arguments
- Application Options:
- -i, --adapter=hciX Specify local adapter interface
- -b, --device=MAC Specify remote Bluetooth address
- -m, --mtu=MTU Specify the MTU size
- -p, --psm=PSM Specify the PSM for GATT/ATT over BR/EDR
- -l, --sec-level=[low | medium | high] Set security level. Default: low
- -I, --interactive Use interactive mode
- gatttool -b 1C::5A:FF:4B:E7 -I
- [ ][1C::5A:FF:4B:E7][LE]> help
- help Show this help
- exit Exit interactive mode
- quit Exit interactive mode
- connect [address] Connect to a remote device
- disconnect Disconnect from a remote device
- primary [UUID] Primary Service Discovery
- characteristics [start hnd [end hnd [UUID]]] Characteristics Discovery
- char-desc [start hnd] [end hnd] Characteristics Descriptor Discovery
- char-read-hnd <handle> [offset] Characteristics Value/Descriptor Read by handle
- char-read-uuid <UUID> [start hnd] [end hnd] Characteristics Value/Descriptor Read by UUID
- char-write-req <handle> <new value> Characteristic Value Write (Write Request)
- char-write-cmd <handle> <new value> Characteristic Value Write (No response)
- sec-level [low | medium | high] Set security level. Default: low
- mtu <value> Exchange MTU for GATT/ATT
- [ ][1C::5A:FF:4B:E7][LE]>
3.4 ubertooth-scan
- root@0xroot:~# ubertooth-scan --help
- ubertooth-scan: invalid option -- '-'
- ubertooth-scan - active(bluez) device scan and inquiry supported by Ubertooth
- Usage:
- -h this Help
- -U<-> set ubertooth device to use
- -s hci Scan - perform HCI scan
- -t scan Time (seconds) - length of time to sniff packets. [Default: 20s]
- -x eXtended scan - retrieve additional information about target devices
- -b Bluetooth device (hci0)
ubertooth-scan -s
3.5 ubertooth-btle
- ubertooth-btle - passive Bluetooth Low Energy monitoring
- Usage:
- -h this help
- Major modes:
- -f follow connections
- -p promiscuous: sniff active connections
- -a[address] get/set access address (example: -a8e89bed6)
- -s<address> faux slave mode, using MAC addr (example: -s22::::aa:cc)
- -t<address> set connection following target (example: -t22::::aa:cc)
- Interference (use with -f or -p):
- -i interfere with one connection and return to idle
- -I interfere continuously
- Data source:
- -U<-> set ubertooth device to use
- Misc:
- -r<filename> capture packets to PCAPNG file
- -q<filename> capture packets to PCAP file (DLT_BLUETOOTH_LE_LL_WITH_PHDR)
- -c<filename> capture packets to PCAP file (DLT_PPI)
- -A<index> advertising channel index (default )
- -v[] verify CRC mode, get status or enable/disable
- -x<n> allow n access address offenses (default )
- If an input file is not specified, an Ubertooth device is used for live capture.
- In get/set mode no capture occurs.
ubertooth-btle -f -c test.pcap抓包&保存到本地
使用这条命令我们可以把设备捕获到的数据包保存到本地,完成后可导入wireshark进行数据包、协议分析。
wireshark导入嗅探到的蓝牙数据包需要处理一下才能正常查看,不然无法正常分析数据:
Edit → Preferences → Protocols → DLT_USER → Edit → New
在payload protocol中输入btle
使用规则过滤数据包:参考Capturing BLE in Wireshark
- btle.data_header.length > || btle.advertising_header.pdu_type == 0x05
3.6 crackle
如果捕获到足够的数据包尤其是btsmp,那接下来便可以用crackle来破解tk和ltk:
- crackle -i <file.pcap>
解密数据包,并把解密后的包另存:
- crackle -i <file.pcap> -o <output.pcap>
- crackle -i <file.pcap> -o <out.pcap> -l <ltk>
0×04 参考 && 感谢
Sniffing and decoding NRF24L01+ and Bluetooth LE packets for under $30
Now I wanna sniff some Bluetooth: Sniffing and Cracking Bluetooth with the UbertoothOne
http://j2abro.blogspot.com.au/2014/06/understanding-bluetooth-advertising.html
路人甲@乌云drops:Bluetooth Low Energy 嗅探
疯狗@乌云drops:物联网安全拔“牙”实战——低功耗蓝牙(BLE)初探
http://j2abro.blogspot.com.au/2014/06/understanding-bluetooth-advertising.html
http://j2abro.blogspot.com.au/2014/06/analyzing-bluetooth-advertising-with.html
https://github.com/greatscottgadgets/ubertooth/wiki/Build-Guide
https://github.com/greatscottgadgets/ubertooth/wiki/Capturing-BLE-in-Wireshark
http://stackoverflow.com/questions/23877761/sniffing-logging-your-own-android-bluetooth-traffic
https://lacklustre.net/bluetooth/wireshark.html
http://www.backtrack-linux.org/forums/showthread.php?t=41552
http://www.splitbits.com/2014/05/14/ubertooth-spectools-chromebook/
http://ubertooth.sourceforge.net/usage/start/
http://hackerific.net/2012/01/28/Spectrum-Tools-and-Ubertooth-One/
https://penturalabs.wordpress.com/2014/02/20/ubertooth-updated-for-2014/
BLE Hacking:使用Ubertooth one扫描嗅探低功耗蓝牙的更多相关文章
- Android使用BLE(低功耗蓝牙,Bluetooth Low Energy)
背景 在学习BLE的过程中,积累了一些心得的DEMO,放到Github,形成本文.感兴趣的同学可以下载到源代码. github: https://github.com/vir56k/bluetooth ...
- Android 蓝牙开发(2)——低功耗蓝牙
低功耗蓝牙官方文档 本文章是参考官网,然后加入自己实践中的理解完成!没有看上一篇的读者,可以先阅读一下前一篇,这是一个系列. 官网地址:https://developer.android.com/gu ...
- 物联网安全拔“牙”实战——低功耗蓝牙(BLE)初探
物联网安全拔“牙”实战——低功耗蓝牙(BLE)初探 唐朝实验室 · 2015/10/30 10:22 Author: FengGou 0x00 目录 0x00 目录 0x01 前言 0x02 BLE概 ...
- 永不消逝的电波(三):低功耗蓝牙(BLE)入门之如何调戏别人的小米手环
0×00 前言 蓝牙(Bluetooth),一种无线技术标准,用来让固定与移动设备,在短距离间交换数据,以形成个人局域网(PAN).其使用短波特高频(UHF)无线电波,经由2.4至2.485 GHz的 ...
- 低功耗蓝牙(BLE)透传模块 ——RF-BM-S01(BQB认证)
本文来源深圳信驰达科技www.szrfstar.com,技术交流群336720020. 低功耗蓝牙(BLE)透传模块 ——RF-BM-S01(BQB认证) 深圳市信驰达科技有限公司 2013年3月18 ...
- 低功耗蓝牙BLE外围模式(peripheral)-使用BLE作为服务端
低功耗蓝牙BLE外围模式(peripheral)-使用BLE作为服务端 Android对外模模式(peripheral)的支持 从Android5.0开始才支持 关键术语和概念 以下是关键BLE术语和 ...
- 深入浅出低功耗蓝牙(BLE)协议栈
深入浅出低功耗蓝牙(BLE)协议栈 BLE协议栈为什么要分层?怎么理解蓝牙"连接"?如果蓝牙协议只有ATT没有GATT会发生什么? 协议栈框架 一般而言,我们把某个协议的实现代码称 ...
- Android BLE与终端通信(五)——Google API BLE4.0低功耗蓝牙文档解读之案例初探
Android BLE与终端通信(五)--Google API BLE4.0低功耗蓝牙文档解读之案例初探 算下来很久没有写BLE的博文了,上家的技术都快忘记了,所以赶紧读了一遍Google的API顺便 ...
- Android低功耗蓝牙(BLE)使用详解
代码地址如下:http://www.demodashi.com/demo/13390.html 与普通蓝牙相比,低功耗蓝牙显著降低了能量消耗,允许Android应用程序与具有更严格电源要求的BLE设备 ...
随机推荐
- JQ的live(),on(),deletage(),bind()几个的区别
今天在网上看到一篇文章,关于JQ里面事件绑定的区别,说说我自己看后的理解,本人菜鸟一枚,很多东西不懂 ,有理解错误的还望大神们多多指教 bind()方法是绑定事件最直接的方法,这个方法是绑定到docu ...
- php常用函数汇总
php常用函数汇总 字符串截取: 1.substr('要截取的字符串','从第几个字符开始','到第几个字符结束'); * 截取英文或者数字 ...
- js中的什么时候需要用new来实例化?
有人说js中函数和类就是一个概念,请问:1 为什么我们在大多数情况下没有用new来实例化一个类(函数),如下 JavaScript code 1 2 3 4 5 6 7 <script> ...
- maven+Jenkins学习小记
jenkins配置方法1,tomcat下载,解压,切换到bin目录,配置环境变量,地址为catalina.bat文件夹下,也就是bin目录,再配置path变量2,启动tomcat,dos命令,cata ...
- Java垃圾回收以及内存分配
http://www.cnblogs.com/ggjucheng/p/3977384.html http://www.blogjava.net/qcyycom/archive/2012/04/14/3 ...
- Sprint(第六天11.19)
燃尽图
- Python编程练习题
1 求可用被17整除的所有三位数 for num in range(99,1000): if num % 17 == 0: print num ps:下面的写法和上面的写法性能的差距,上面好吧? fo ...
- HQL 参数绑定、唯一结果、分页、投影总结(上)
我们先总结一下HQL语句常用语法: from子句:; select子句:用于选取对象和属性; where子句:用于表达查询语句的限制条件; 使用表达式:一般用在where子句中; order by子句 ...
- 用友华表Cell一些用法小结(cs.net版本)
//从Color类型得到RGB类型,也可以用ColorTranslator.ToOle()方法 public int GetRGBFromColor(Color color) { byte r = c ...
- [分享] WIN7x64封装体积小于4G制作过程
raymond 发表于 2015-11-1 18:27:17 https://www.itsk.com/thread-359041-1-1.html 前人栽树,后人乘凉!感谢各位大神的作品!我只是按部 ...