Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert Google Chrome sqlite Cookies into cookies.txt. Useful for utilities like curl.
sqlite3 -separator ' ' ${COOKIES:-Cookies} \
'select host_key, "TRUE", path, "FALSE", expires_utc, name, value from cookies'
#!/bin/sh
# curl -ks https://raw.github.com/gist/1443588/cookies-txt.sh | sh
STARTD=${PWD}
NOW=$(date -u +%Y%m%dt%H%M%S)
HOST=${HOSTNAME:-$(hostname)}
UNQ=${NOW}.${RANDOM}.$$
COOKIES=/tmp/${UNQ}
date
CHROME="${1:-${HOME}/Library/Application Support/Google/Chrome/Default}"
[ -d "${CHROME}" ] && cd "${CHROME}"
[ -r Cookies ] || exit 1
umask 0077
t=${STARTD}/cookies.txt
: </dev/null >${t}
trap "rm -f ${COOKIES}" 0
cp Cookies ${COOKIES}
curl -ks https://raw.github.com/gist/1443588/chrome-cookies.sh \
| sh \
>> ${STARTD:-.}/cookies.txt
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment