Skip to content

Instantly share code, notes, and snippets.

@AndrewWCarson
Last active August 23, 2018 04:52
Show Gist options
  • Select an option

  • Save AndrewWCarson/395ced9ab707672f0b44c34b70c3f38d to your computer and use it in GitHub Desktop.

Select an option

Save AndrewWCarson/395ced9ab707672f0b44c34b70c3f38d to your computer and use it in GitHub Desktop.
Iterate through all users and export their Chrome history to .csv in /tmp
#!/bin/bash
# (C) Andrew Worth Carson
# MIT License: https://andrewworthcarson.com/mit_license.html
for user in $(dscl . list /Users UniqueID | awk '$2 >= 500 {print $1}'); do
userHome=$(dscl . read /Users/"$user" NFSHomeDirectory | sed 's/NFSHomeDirectory://' | grep "/" | sed 's/^[ \t]*//')
if cp "${userHome}/Library/Application Support/Google/Chrome/Default/History" "/tmp/${user}-History"; then
if sqlite3 "/tmp/${user}-History" <<EOF
.headers on
.mode csv
.output /tmp/${user}-History.csv
SELECT datetime(last_visit_time/1000000-11644473600,'unixepoch','localtime'), url FROM urls ORDER BY last_visit_time DESC
EOF
then
echo "Created /tmp/${user}-History.csv"
fi
rm "/tmp/${user}-History"
fi
done
@AndrewWCarson

Copy link
Copy Markdown
Author

This script is designed to be run as root from a mgmt platform like Addigy. The .csv files will be listed as in stdout and can be easily curled or slackbotted up to your preferred fileserver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment