-
-
Save henrik242/1da3a252ca66fb7d17bca5509a67937f to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash | |
# | |
# Reads AirTag data from the FindMy.app cache and converts it to a daily GPX file | |
# | |
# Rsyncs the data to a web accessible folder that can be displayed with e.g. | |
# https://gist.github.com/henrik242/84ad80dd2170385fe819df1d40224cc4 | |
# | |
# This should typically be run as a cron job | |
# | |
set -o pipefail -o nounset -o errexit | |
export PATH=/usr/local/bin:$PATH | |
DATADIR=/tmp/airtag-data | |
TODAY=$(date +%d) | |
mkdir -p $DATADIR | |
DATA=$DATADIR/airtagdata-$TODAY.txt | |
GPX=$DATADIR/airtagdata-$TODAY.gpx | |
TAGNAME=Foobar | |
if [[ $(uname -s) == "Darwin" ]]; then | |
TOMORROW=$(date -v +1d +%d) | |
else | |
TOMORROW=$(date --date="tomorrow" +%d) | |
fi | |
rm -f $DATADIR/airtagdata-$TOMORROW.gpx | |
jq -r '.[] | select(.name == "'$TAGNAME'") | .location | "\(.latitude) \(.longitude) \(.altitude) \(.timeStamp/1000 | todate)"' \ | |
$HOME/Library/Caches/com.apple.findmy.fmipcore/Items.data >> $DATA | |
START='<?xml version="1.0" encoding="UTF-8"?> | |
<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:mytracks="http://mytracks.stichling.info/myTracksGPX/1/0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" creator="myTracks" version="1.1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"> | |
<trk> | |
<name>'$TAGNAME'</name> | |
<extensions> | |
<mytracks:color red="0.000000" green="0.000000" blue="1.000000" alpha="1.000000" /> | |
<mytracks:area showArea="no" areaDistance="0.000000" /> | |
<mytracks:directionArrows showDirectionArrows="yes" /> | |
<mytracks:sync syncPhotosOniPhone="no" /> | |
<mytracks:timezone offset="120" /> | |
</extensions> | |
<trkseg>' | |
END=' </trkseg> | |
</trk> | |
</gpx>' | |
echo $START > $GPX | |
function elems() { | |
LAT=$1 | |
LON=$2 | |
ELE=$3 | |
TS=$4 | |
} | |
cat $DATA | while read line; do | |
elems $line | |
echo '<trkpt lat="'$LAT'" lon="'$LON'"> | |
<ele>'$ELE'</ele> | |
<time>'$TS'</time> | |
</trkpt>' >> $GPX | |
done | |
echo $END >> $GPX | |
cp $GPX $DATADIR/airtagdata.gpx | |
rsync -a --exclude='*.txt' $DATADIR example.com:public_html/airtag/ |
A full decryption tool for macOS 14.4+ FindMy cache data has been published at https://github.com/Pnut-GGG/findmy-cache-decryptor
Were you able to get it working?
I've been testing it, but the key I retrieved from the keychain doesn't successfully decrypt the data.
Despite multiple attempts to regenerate or extract alternative keys, decryption consistently fails with an invalid tag error
invalid tag error
That's discouraging, what version of MacOS did you try this on?
invalid tag error
That's discouraging, what version of MacOS did you try this on?
I'm getting the same error too. Do you know if there's any way to get around it?
It's happening to me on macOS 14.7.6 and 15.5
@hubert3
@marcelosanchez Maybe try posting an issue at the repo
Can someone advice which MacOS version can be virtualized and allows for reading the location of a shared AirTag?
Can someone advice which MacOS version can be virtualized and allows for reading the location of a shared AirTag?
I had the most success with Monterey under VirtualBox. Ventura and beyond introduced major kernel changes that break compatibility with VirtualBox's emulation, especially with how Ventura++ handles devices and memory.
Super helpful! Were you able to make this work on a EC2 instance or similar hosting provider?
Super helpful! Were you able to make this work on a EC2 instance or similar hosting provider?
Never tried MacOS on AWS but likely works, the key is keeping the terminal in the foreground for the FindMy app so if that works it may work. Let me know if you are able to test it.
I have tried it multiple times with macOS Sonoma (as I would love to access data of shared AirTags), but I couldn't even get the version from archive.org to boot on my local host.
Nice!