Agnus Dei (jackal) wrote,
Agnus Dei
jackal

How to convert a cookies.sqlite to cookies.txt for usage with curl or wget

I found this online and can't find the original author so all apologies to the original author.

This script converts the new cookies.sqlite file into a classic cookies.txt file (so you can use it with curl or wget):

#!/bin/bash

function cleanup {
rm -f $TMPFILE
exit 1
}

trap cleanup  SIGHUP SIGINT SIGTERM

# This is the format of the sqlite database:
# CREATE TABLE moz_cookies (id INTEGER PRIMARY KEY, name TEXT, value TEXT, host TEXT, path TEXT,expiry INTEGER, lastAccessed INTEGER, isSecure INTEGER, isHttpOnly INTEGER);

# We have to copy cookies.sqlite, because FireFox has a lock on it
TMPFILE=`mktemp /tmp/cookies.sqlite.XXXXXXXXXX`
cat $1 >> $TMPFILE
sqlite3 -separator '    ' $TMPFILE << EOF
.mode tabs
.header off
select host,
case substr(host,1,1)='.' when 0 then 'FALSE' else 'TRUE' end,
path,
case isSecure when 0 then 'FALSE' else 'TRUE' end,
expiry,
name,
value
from moz_cookies;
EOF
cleanup
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 0 comments