-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplay_functions.sh
More file actions
277 lines (201 loc) · 6.47 KB
/
display_functions.sh
File metadata and controls
277 lines (201 loc) · 6.47 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#!/bin/bash
display_last3s () {
while true; do
#find new ssids in last 3 seconds
x=1
while read -r line; do
rssi2=0
range=''
IFS='|' read -r -a arr <<<"$line"
ssid="$(echo -n ${arr[0]} | xxd -r -p)"
ssid_hex="${arr[0]}"
wlan_sa=${arr[1]}
rssi=${arr[2]}
rssi2=$(echo ${arr[2]}| cut -d\, -f1)
if [[ $rssi2 -gt -66 ]]
then
if [[ $rssi2 -ne 0 ]]; then
range=near\ by
fi
else
if [[ $rssi2 -gt -82 ]]
then
range=medium
else
range=far
fi
fi
vendor=$(sqlite3 ssid.db "select distinct vendor from ssid where wlan_sa=\"$wlan_sa\" and vendor is not null;")
if [[ -n $ssid ]]; then
echo -e Network: $ssid \\nProxity: $range $rssi2 \\nVendor: $vendor | grep -v "Vendor: ." | egrep -v 'Vendor:$'
fi
sqlite3 ssid_intel.db ".mode line" ".headers on" "select category,location,is_name,is_airport,is_common,is_oneloc from ssid_intel where ssid_hex=\"$ssid_hex\";" | egrep -v '= 0' | egrep -v 'location = $'
related_burst=$(sqlite3 bursts.db "select distinct related_burst from bursts where ssids like \"%:$ssid_hex:%\" or ssids like \":$ssid_hex%\" or ssids like \"%$ssid_hex:\";")
#IFS=\:
while read a
do
if [[ -n $a ]]; then
if [ "$a" != "$ssid_hex" ]; then
echo
echo Related Network: $(echo -n $a | xxd -r -p)
fi
fi
sqlite3 ssid_intel.db ".mode line" ".headers on" "select category,location,is_name,is_airport,is_common,is_oneloc from ssid_intel where ssid_hex=\"$a\";" | egrep -v '= 0'
done <<< $(sqlite3 bursts.db "select ssids from bursts where related_burst=\"$related_burst\";"| tr \: \\n | sort -u)
#tput cup 4 4
#sqlite3 new.db "select * from ssid_intel where ssid_hex=\"$ssid_hex\"; "
#sqlite3 new.db "select vendor from ssid where ssid_hex=\"$ssid_hex\"; "
#((x++))
ssid_hex=''
done <<<$(sqlite3 ssid.db "select ssid_hex,wlan_sa,rssi from ssid where time > $(date +%s --date=30000\ sec\ ago) group by ssid_hex order by rssi;")
#display intel
sleep 3
#echo
done
}
display_burstinfo3s () {
while true; do
#When SSID is seen, match ssid to ssids of burst, pull related burst ssids, pull all info of all ssids from ssid_intel
#Mark VIP as needed
###
while read -r ssid_hex; do
related_burst=$(sqlite3 bursts.db "select distinct related_burst from bursts where ssids like \"%:$ssid_hex:%\" or ssids like \":$ssid_hex%\" or ssids like \"%$ssid_hex:\";")
IFS=\:
for a in $(sqlite3 bursts.db "select ssids from bursts where related_burst=\"$related_burst\";")
do
echo -n $a | xxd -r -p
echo
sqlite3 ssid_intel.db $"select * from ssid_intel where ssid_hex=\"$a\";"
done
done <<<$(sqlite3 ssid.db "select distinct ssid_hex from ssid where time > $(date +%s --date=3\ sec\ ago) group by ssid_hex order by rssi;")
sleep 3
done
}
display_ssid () {
while read -r line; do
#echo $line
rssi2=0
range=''
IFS='|' read -r -a arr <<<"$line"
ssid="$(echo -n ${arr[0]} | xxd -r -p)"
ssid_hex="${arr[0]}"
wlan_sa=${arr[1]}
rssi=${arr[2]}
rssi2=$(echo ${arr[2]}| cut -d\, -f1)
vendor=$(sqlite3 ssid.db "PRAGMA journal_mode=WAL;" "select distinct vendor from ssid where wlan_sa=\"$wlan_sa\" and vendor is not null;" | sed 's/wal//g')
if [[ -n $ssid ]]; then
echo $ssid $rssi2 $vendor
sleep .5
fi
#done <<<$(sqlite3 new.db "select distinct ssid_hex from ssid where time > $(date +%s --date=3\ sec\ ago) group by ssid_hex order by time;")
done <<<$(sqlite3 ssid.db "PRAGMA journal_mode=WAL;" "select ssid_hex,wlan_sa,rssi from ssid where time > $(date +%s --date=3\ sec\ ago) group by ssid_hex order by rssi;")
}
displayburst_simple_vht () {
time=$(date +%s)
begintime=$( echo "scale=7; $time - .000001" | bc)
row=$(sqlite3 ssid.db "select * from ssid ssid_hex not like '%000%' and ssid_hex not like '%fff%' and rssi is not null and vht is not null limit 1;")
IFS=\|
arr=($row)
if [[ -z ${arr} ]]
then
echo ending vht
sleep 5
return
fi
ssid_hex=${arr[0]}
wlan_sa=${arr[1]}
time=${arr[2]}
rssi=$(echo ${arr[3]} | cut -d, -f1)
#echo $rssi
vht=${arr[4]}
end_time=`echo "scale=7; $time + 1" | bc`
#endtime=`echo $end_time | cut -d\. -f1`
endtime=$end_time
#time3=`echo $time | cut -d. -f1`
#begintime=$time
begintime=$( echo "scale=7; $time - .000001" | bc)
((rssi_max=rssi+5))
((rssi_min=rssi-5))
while read line;
do
#echo $line
if [[ -z $line ]]
then
sqlite3 ssid.db "update ssid set is_processed=2 where wlan_sa = \"$wlan_sa\" and time =\"$time\";"
echo no other vhts found, breaking $vht $ssid_hex
break
fi
IFS=\|
arr2=($line)
ssid_hex2=${arr2[0]}
wlan_sa2=${arr2[1]}
time2=${arr2[2]}
rssi2=${arr2[3]}
vht2=${arr2[4]}
#append ssid of matching mac address to burst
#unset IFS
burst+=("$ssid_hex2")
sqlite3 ssid.db "update ssid set is_processed=100 where wlan_sa = \"$wlan_sa2\" and time =\"$time2\";"
final_time=$time2
#query for 1 second in the future and iterate through probes to find match
#sqlite3 messes up on greater/less than of negative numbers so operators are reversed
done <<<$(sqlite3 ssid.db "SELECT ssid_hex,wlan_sa,time,rssi,vht from ssid where time < \"$endtime\" and time > \"$begintime\" and rssi > \"$rssi_max\" and rssi < \"$rssi_min\" and vht=\"$vht\";")
bcount=${#burst[@]}
newburst=$(echo ${burst[*]} | tr \ \:)
bdur=$(echo "scale=7; $final_time - $time" | bc)
if [[ $bcount -gt "1" ]]
then
echo ${#burst[@]}
fi
}
row_1() {
x=0
#date=$(date -d '08/09/2024 19:40:22' +"%s")
#date=1720470846
#date=$(date +"%s")
date=$((($(date +%s)-5)))
x=1
while read -r line; do
rssi2=0
range=''
IFS='|' read -r -a arr <<<"$line"
ssid="$(echo -n ${arr[0]} | xxd -r -p)"
ssid_hex="${arr[0]}"
wlan_sa=${arr[1]}
rssi=${arr[1]}
rssi2=$(echo ${arr[1]}| cut -d\, -f1)
if [[ $rssi2 -gt -66 ]]
then
if [[ $rssi2 -ne 0 ]]; then
range=close
fi
else
if [[ $rssi2 -gt -82 ]]
then
range=medium\ range
else
range=far
fi
fi
#tput cup $x 0
echo
echo $ssid $range
((x++))
#tput cup $x 0
echo -n $(sqlite3 ssid_intel.db "select category from ssid_intel where ssid_hex=\"$ssid_hex\";")
echo $(sqlite3 ssid_intel.db "select location from ssid_intel where ssid_hex=\"$ssid_hex\";")
((x++))
airport=$(sqlite3 ssid_intel.db "select is_airport from ssid_intel where ssid_hex=\"$ssid_hex\" and is_airport!=0;")
#tput cup $x 0
echo $airport
((x++))
#tput cup $x 0
echo -n $(sqlite3 ssid_intel.db "select is_name from ssid_intel where ssid_hex=\"$ssid_hex\" and is_name!=0;") \
is_oneloc=$(sqlite3 ssid_intel.db "select is_oneloc from ssid_intel where ssid_hex=\"$ssid_hex\" and is_name!=0;")
if [[ $is_oneloc -eq 1 ]]
then
echo Single Location
fi
((x++))
done <<< $(sqlite3 ssid.db "select ssid_hex,rssi from ssid where ssid_hex!=\"<MISSING>\" and time>$date group by ssid_hex;")
}