hackgnar / pyubertooth

Python libraries for Ubertooth
GNU General Public License v2.0
52 stars 18 forks source link

PyUbertooth

Project Description:

Core PyUbertooth Libraries:

Core PyUbertooth Tools:

Upcoming Milestones:


Core CLI Script: pyubertooth_rx

Sample command line usage:

For usage help:
pyubertooth_rx --help
To log ubertooth data to a file (usable with ubertooth-rx -i filename):
pyubertooth_rx --outfile=dump_filename.dump
To log ubertooth data directly to a file from bluetooth channel 60:
pyubertooth_rx --outfile=dump_filename.dump --channel 60
To log 30 seconds worth of ubertooth data directly to a file :
pyubertooth_rx --outfile=dump_filename.dump -t 30
To log 300 ubertooth usb data packets directly to a file :
pyubertooth_rx --outfile=dump_filename.dump -n 300
To read raw ubertooth usb data from a dump file to std out:
pyubertooth_rx --infile=dump_filename.dump
To display bluetooth packet information from a dump file (LAP, UAP, channel, etc):
pyubertooth_rx --infile=dump_filename.dump --btbb
To display bluetooth packet information from a live stream (LAP, UAP, channel, etc):
pyubertooth_rx --btbb

Sample python library usage:

To open a connection to an ubertooth device:
from pyubertooth.ubertooth import Ubertooth
ut = Ubertooth()
To access 5 data blocks from an ubertooth device as a python iterator:
from pyubertooth.ubertooth import Ubertooth
ut = Ubertooth()
for data in ut.rx_stream(count=5):
    print(data)
ut.close()
To access data blocks from an ubertooth device as a python iterator for 30 seconds:
from pyubertooth.ubertooth import Ubertooth
ut = Ubertooth()
for data in ut.rx_stream(secs=30):
    print(data)
ut.close()
To access data from an ubertooth device until ctrl-C is pressed:
from pyubertooth.ubertooth import Ubertooth
ut = Ubertooth()
try:
    for data in ut.rx_stream():
        print(data)
except KeyboardInterrupt:
    pass
ut.close()
An example of directly streaming ubertooth data to a file for 60 seconds:
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()
Changing the channel on an ubertooth device:
from pyubertooth.ubertooth import Ubertooth 
ut = Ubertooth()
ut.set_channel(66)

Core Library: pylibbtbb/bluetooth_packet.py

Sample python library usage:

To display bluetooth packet data for an ubertooth device stream:
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()

Core Tools: tools/ubertooth_dump.py

To dump data from an ubertooth to a file:

python ubertooth_dump.py dump_filename.dump