-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathwherehaveibeen.sh
executable file
·67 lines (56 loc) · 1.38 KB
/
wherehaveibeen.sh
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
#!/bin/bash
function coordsToAddress
{
local x="$1" y="$2" lang=en
[[ "$LANG" == ru* ]] && lang=ru
curl -s "http://data.esosedi.org/geocode/v1?lng=$lang&point=$x,$y" |
awk -F: '/"name"/ {print $2}' | xargs echo | sed 's/,$//;s/, *,/,/g'
}
function macToCoords
{
local mac="$1"
local where=$(curl -s "https://api.mylnikov.org/wifi/main.py/get?bssid=$mac" 2>&-)
if [[ "$where" == *'"result":200'* ]]; then
echo $(grep -Eo '"(lat|lon)": *[^ ",]*'<<<"$where" | xargs echo)
fi
}
function macToAddress
{
local mac="$1"
local coords=$(macToCoords "$1")
if [[ "$coords" != "" ]]; then
if [[ "$coords" == 'lon'* ]]; then
local xy=$(awk '{print $4" "$2}' <<< "$coords")
else
local xy=$(awk '{print $2" "$4}' <<< "$coords")
fi
local address=$(coordsToAddress $xy)
if [[ "$address" == "" ]]; then
address='N/A'
fi
else
address='N/A'
coords='N/A'
fi
echo -e "BSSID: $mac\nAddress: $address\nGeo: $coords"
}
MASK='(BSSID changed|UserEventAgent.*Probing)'
fgrep -B1 'Probing' < <(zgrep -Eh "$MASK" /var/log/system.log.*.gz ; grep -Eh "$MASK" /var/log/system.log) |
while read line; do
case "$line" in
*BSSID*)
mac=$(grep -o '[^ ]*$' <<<"$line")
;;
*Probing*)
name=$(sed "s/^.*Probing *'//;s/'$//" <<<"$line")
echo "$mac $name"
mac=
;;
esac
done | sort -u |
while read line; do
line=($line)
echo "Name: ${line[@]:1}"
macToAddress "${line[0]}"
echo
done