Last active
August 23, 2018 04:52
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.