Skip to content

Instantly share code, notes, and snippets.

@Mattias-
Last active August 29, 2015 14:13
Show Gist options
  • Save Mattias-/c02d46074a359c59a763 to your computer and use it in GitHub Desktop.
Save Mattias-/c02d46074a359c59a763 to your computer and use it in GitHub Desktop.
#!/bin/bash
security find-certificate -a /System/Library/Keychains/SystemRootCertificates.keychain
#!/bin/bash
function get_root_cert() {
host=$1
echo x |
openssl s_client -connect $host:443 2> /dev/null |
sed -n "s/.*:\/C=.*CN=\(.*\)$/\1/p" |
tail -1
}
query="
SELECT DISTINCT
substr(url, 9, instr(substr(url, 9), '/') - 1)
FROM urls
WHERE url
LIKE 'https%';
"
#histfile="History"
histfile="$HOME/Library/Application Support/Google/Chrome/Default/History"
temphistory="./temphistory"
# Copy the history since it's probably locked by Chrome
cp "$histfile" "$temphistory"
# Get all hosts from the history sqlite file that use HTTPS
sqlite3 "$temphistory" "$query" > urls.dump
hosts=$(tail -5 urls.dump)
#hosts=$(cat urls.dump)
rm -f certs.dump
for host in $hosts ; do
get_root_cert $host >> certs.dump
done
sort certs.dump | uniq -c | sort -nr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment