-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathubertooth-bt-tracker.py
102 lines (95 loc) · 4.4 KB
/
ubertooth-bt-tracker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/python3
import subprocess
import re
import os, sys
import time, threading
import datetime
from gps3 import agps3
# Print Banner
print('')
print(' kNXK0OOOkkOOO0KXNk ')
print(' dNX0OOkkkkkkkkkkkkkkkkOO0XNd ')
print(' ;N0OkkkkkkkkkkdokkkkkkkkkkkkkkO0N: ')
print(' ,XOkkkkkkkkkkkkkx okkkkkkkkkkkkkkkOX; ')
print(' OOkkkkkkkkkkkkkkkx ckkkkkkkkkkkkkkkO0 ')
print(' XOkkkkkkkkkkkkkkkkx :kkkkkkkkkkkkkkOX ')
print(' 0kkkkkkkkkkkkkkkkkkx ;kkkkkkkkkkkkkkK ')
print(' dOkkkkkkkkkkkkkkkkkkx ,kkkkkkkkkkkkkd ')
print(' .Okkkkkkkkkkkkkkkkkkkx .o kkkkkkkkkkkO' )
print(' xkkkkkkkkkd ;kkkkkkkx .OKd .kkkkkkkkkkx')
print(' Okkkkkkko ,kkkkkx .kkOKx .kkkkkkkkO')
print(';kkkkkkkkOXo kkkx .kkkk NOkkkkkkkk')
print('okkkkkkkkkkOKx .kx .kx N0kkkkkkkkkk')
print('xkkkkkkkkkkkkOKk .N0kkkkkkkkkkkk')
print('kkkkkkkkkkkkkkkOKO .N0kkkkkkkkkkkkkk')
print(' u b e r t o o t h o n e ')
print('kkkkkkkkkkkkkkkkkkkOKx .XOkkkkkkkkkkkkkkkkkk')
print('kkkkkkkkkkkkkkkkkkkc kkkkkkkkkkkkkkkkkk')
print('kkkkkkkkkkkkkkkkk: kkkkkkkkkkkkkkkk')
print('dkkkkkkkkkkkkkk; . xkkkkkkkkkkkkk')
print('lkkkkkkkkkkkk, lXx .0N. dkkkkkkkkkkk')
print(',kkkkkkkkkk dKOkx .kk0N. dkkkkkkkkk')
print(' kkkkkkkkk xKOkkkx .kkkk; cOkkkkkkkk')
print(' lkkkkkkkk0N kKOkkkkkx .kk lXOkkkkkkkkl')
print(' .kkkkkkkkkk0KOkkkkkkkx .. dKOkkkkkkkkkk.')
print(' :kkkkkkkkkkkkkkkkkkkx xKOkkkkkkkkkkkc ')
print(' b l u e t o o t h t r a c k e r ')
print(' xkkkkkkkkkkkkkkkkkx 0KOkkkkkkkkkkkkkd ')
print(' lkkkkkkkkkkkkkkkkx KKOkkkkkkkkkkkkkkl ')
print(' .kkkkkkkkkkkkkkkx N0Okkkkkkkkkkkkkkk. ')
print(' kkkkkkkkkkkkkxN0kkkkkkkkkkkkkkkk. ')
print(' .kkkkkkkkkkOkkkkkkkkkkkkkkk. ')
print(' dkkkkkkkkkkkkkkd ')
print('')
gpsd_socket = agps3.GPSDSocket()
data_stream = agps3.DataStream()
gpsd_socket.connect()
gpsd_socket.watch()
def trackBT():
print("Start bluetooth discovering")
basename = "mylogfile"
suffix = datetime.datetime.now().strftime("%y%m%d_%H%M%S")
filename = "_".join([basename, suffix])
myfile = open(filename,"w")
while 1:
try:
print("new scan")
p = subprocess.Popen(["ubertooth-scan", "-U 0 -b hci0 -x -t 40"],shell=True,stdout=subprocess.PIPE)
out = p.stdout.read()
for line in out.decode().split("\n"):
print(line)
try:
regObj = re.search(r'(\sLAP\=(.*?)\s)(.*)(\ss\=(.*?)\s)', line)
lap = regObj.group(2)
s = regObj.group(5)
s_num = re.sub(r'(?i)\-+','',s)
n = int(s_num)
if lap is not None and n < 65:
print("found a close BT device")
print('MAC = ', lap)
print('Signal =', s)
print('signal num =', s_num)
for new_data in gpsd_socket:
if new_data:
data_stream.unpack(new_data)
if data_stream.lon != 'n/a' and data_stream.lat != 'n/a':
longitude = data_stream.lon
latitude = data_stream.lat
print('Longitudine = ', data_stream.lon)
print('Latitude = ', data_stream.lat)
break
t = input("Enter track note:")
print("log data into file")
myfile.write("MAC: " + str(lap))
myfile.write(" Signal " + str(s))
myfile.write(" LONG: " + str(longitude))
myfile.write(" LAT: " + str(latitude))
myfile.write(" Note: " + str(t))
myfile.write("\n\n")
except AttributeError:
print('')
except KeyboardInterrupt:
myfile.close()
os.system("ubertooth-util -r")
sys.exit("quit scan")
trackBT()