ubertooth的纯python库
pyubertooth的Python项目详细描述
侏儒
- ubertooth的python库
项目描述:
- pyubertooth的目标是提供与python中的ubertooth设备交互的库和工具。
- pyubertooth提供的所有模块和库都提供纯python实现。
- cpython实现将在未来提供,但将始终有纯python的替代方案。
核心pyubertooth库:
- py ubertooth/ubertooth.py:提供对ubertooth设备的直接访问。
- py ubertooth/bluetooth_packet.py:提供将ubertooth数据转换为蓝牙基带数据的方法和数据结构。
核心pyubertooth工具:
- pyubertooth_x rx:这个文件提供了一些cli功能来控制ubertooth。
- ubertooth_dump:将数据从ubertooth设备转储到文件的简单脚本。此转储数据与Ubertooth C库和工具兼容(即与Ubertooth RX工具的-i标志一起使用)。
即将到来的里程碑:
- 完成所有USB获取/设置/模式命令功能(WIP)的移植
- 库仍然缺少详细的文档字符串。这些将很快添加,我所有无用的评论都将被清除
- 重写我的纯python libbtbb lib(wip)
- 创建cTypes libbtbb绑定(WIP)
- 重写我的Ubertooth Scapy RX层
- 创建Ubertooth scapy tx层
核心cli脚本:pyubertooth_x rx
- Ubertooth设备的纯Python接口。
- TOdo:切换到*args,**kwargs用于我的argparse方法
- 待办事项:许多简单的Ubertooth USB控件将很快添加(如LED控件等)
- TOdo:完整的Python库文档。
命令行用法示例:
使用帮助:
pyubertooth_rx --help
将ubertooth数据记录到文件(可与ubertooth rx-i文件名一起使用):
pyubertooth_rx --outfile=dump_filename.dump
从蓝牙通道60将Ubertooth数据直接记录到文件:
pyubertooth_rx --outfile=dump_filename.dump --channel 60
将30秒的Ubertooth数据直接记录到文件中:
pyubertooth_rx --outfile=dump_filename.dump -t 30
将300个Ubertooth USB数据包直接记录到文件:
pyubertooth_rx --outfile=dump_filename.dump -n 300
从转储文件读取Ubertooth USB原始数据到STD输出:
pyubertooth_rx --infile=dump_filename.dump
显示来自转储文件(LAP、UAP、通道等)的蓝牙数据包信息:
pyubertooth_rx --infile=dump_filename.dump --btbb
显示来自实时流(LAP、UAP、信道等)的蓝牙数据包信息:
pyubertooth_rx --btbb
python库使用示例:
打开到Ubertooth设备的连接:
from pyubertooth.ubertooth import Ubertooth
ut = Ubertooth()
作为python迭代器从ubertooth设备访问5个数据块:
from pyubertooth.ubertooth import Ubertooth
ut = Ubertooth()
for data in ut.rx_stream(count=5):
print data
ut.close()
作为python迭代器从ubertooth设备访问数据块30秒:
from pyubertooth.ubertooth import Ubertooth
ut = Ubertooth()
for data in ut.rx_stream(secs=30):
print data
ut.close()
从Ubertooth设备访问数据,直到按下CTRL-C:
from pyubertooth.ubertooth import Ubertooth
ut = Ubertooth()
try:
for data in ut.rx_stream():
print data
except KeyboardInterrupt:
pass
ut.close()
将Ubertooth数据直接流式传输到文件60秒的示例:
from pyubertooth.ubertooth import Ubertooth
ut = Ubertooth()
f = open("dump_filename.dump", 'wb')
for data in ut.rx_stream(secs=60):
f.write(data)
f.close()
ut.close()
在Ubertooth设备上更改频道:
from pyubertooth.ubertooth import Ubertooth
ut = Ubertooth()
ut.set_channel(66)
核心库:pylibbtbb/bluetooth_packet.py
- 这是来自libbtbb的蓝牙数据包的纯python实现。它充当python应用程序的库。它目前还处于早期阶段,基于c库libbtbb和一些难看的poc代码
- lap&;channel检测正在工作(仍需要清理)。
- uap和包类型检测仍然需要从我的alpha poc代码中移植。
- TOdo:使用纯Python模块位向量。
- 待办事项:像c libbtbb一样酷
python库使用示例:
显示Ubertooth设备流的蓝牙数据包:
from pyubertooth.ubertooth import Ubertooth()
from pyubertooth.bluetooth_packet import BtbbPacket
ut = Ubertooth()
for data in ut.rx_stream():
print BtbbPacket(data=data)
ut.close()
核心工具:tools/ubertooth_dump.py
- 一个简单的独立纯python脚本,将ubertooth中的数据转储到文件中。转储格式与ubertooth rx工具兼容。这允许DAta将在python中收集,并与核心ubertooth库一起解析。
将数据从ubertooth转储到文件:
python ubertooth_dump.py dump_filename.dump