LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 07-02-2008, 10:22 PM   #1
jimbo1708
Member
 
Registered: Jan 2007
Location: Pennsylvania
Distribution: Ubuntu 8.10 Server/9.04 Desktop, openSUSE 11.1
Posts: 154

Rep: Reputation: 31
Using the cookies.sqlite from Firefox 3 in wget


Hey everyone,

I am trying to automate a periodic downloading script I have for a website. I want to use wget to grab the file, but I need to use my cookies from Firefox 3 to bypass the login. Wget allows you to specify a cookies.txt file when you invoke wget, but Firefox 3 does not use cookies.txt but rather cookies.sqlite. Does anyone know if a firefox extension is in the works to create a work around. Does anyone have any other suggestions?

Thanks,
- Jim
 
Old 07-03-2008, 03:18 AM   #2
storkus
Member
 
Registered: Jun 2008
Posts: 310

Rep: Reputation: 45
I would suggest taking this up in a FF3 or wget-specific group since this is such a specific question.

Mike
 
Old 07-03-2008, 05:02 PM   #3
jimbo1708
Member
 
Registered: Jan 2007
Location: Pennsylvania
Distribution: Ubuntu 8.10 Server/9.04 Desktop, openSUSE 11.1
Posts: 154

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by storkus View Post
I would suggest taking this up in a FF3 or wget-specific group since this is such a specific question.

Mike
Do you know of any such communities.? I am use to using LQ as my main resource. With the release of FF3 so recently, I hope their is a solution.

- Jim
 
Old 07-04-2008, 03:17 AM   #4
ogn.alice
LQ Newbie
 
Registered: Jul 2008
Location: New Zealand
Distribution: Ubuntu
Posts: 2

Rep: Reputation: 0
Jim, I had the same problem. I found a solution from icewind in this blog post. It uses a python script to extract the data from cookies.sqlite.

The post is written in German, but a version of the script (heavily) commented in English is also provided. The link to it is labelled "vollständig dokumentierte Version des Scriptes" and appears just after the python code.

- Alice
 
Old 07-05-2008, 11:26 AM   #5
jimbo1708
Member
 
Registered: Jan 2007
Location: Pennsylvania
Distribution: Ubuntu 8.10 Server/9.04 Desktop, openSUSE 11.1
Posts: 154

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by ogn.alice View Post
Jim, I had the same problem. I found a solution from icewind in this blog post. It uses a python script to extract the data from cookies.sqlite.

The post is written in German, but a version of the script (heavily) commented in English is also provided. The link to it is labelled "vollständig dokumentierte Version des Scriptes" and appears just after the python code.

- Alice
Thanks, the python script worked. It took me a little bit to figure out that i needed to pass in an argument to search for, but its working well for my purposes.

- Jim
 
Old 08-01-2008, 02:33 PM   #6
ssokolow
LQ Newbie
 
Registered: Aug 2004
Location: Canada
Posts: 24

Rep: Reputation: 16
For future reference, there's now an extension in development for this (experimental as of this posting) available at https://addons.mozilla.org/en-US/firefox/addon/8154
 
Old 03-12-2009, 05:22 PM   #7
Ladadadada
LQ Newbie
 
Registered: Mar 2009
Location: London
Distribution: Mac OS X, Solaris, Ubuntu, Debian, Redhat
Posts: 2

Rep: Reputation: 0
Even easier than using Python and the script...

If you have sqlite3 on your system (Mac OS X does by default and I'm sure most Linux distros do by default too) then you can just type this in the appropriate folder:

sqlite3 -separator ' ' cookies.sqlite 'select * from moz_cookies' > cookies.txt

(That's a tab-space in the quotes after -separator. If you need to type a tab-space on the command line, type a ctrl-v first.)

You can also use sqlite3 to edit and selectively delete cookies if you know a little bit of SQL.
 
Old 03-24-2009, 11:13 PM   #8
sandhawke
LQ Newbie
 
Registered: Mar 2009
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by Ladadadada View Post
If you have sqlite3 on your system (Mac OS X does by default and I'm sure most Linux distros do by default too) then you can just type this in the appropriate folder:

sqlite3 -separator ' ' cookies.sqlite 'select * from moz_cookies' > cookies.txt

(That's a tab-space in the quotes after -separator. If you need to type a tab-space on the command line, type a ctrl-v first.)

You can also use sqlite3 to edit and selectively delete cookies if you know a little bit of SQL.
That didn't work for me, but the python script did. On my system, the order of the columns in the sqlite database is wrong; maybe mozilla changed it.

The schema for me (running 3.0.7) is:
Code:
    CREATE TABLE moz_cookies (id INTEGER PRIMARY KEY, name TEXT, value TEXT, host TEXT, path TEXT,expiry INTEGER, lastAccessed INTEGER, isSecure INTEGER, isHttpOnly INTEGER);
This schema also has isSecure and isHttpOnly as integers instead of "TRUE"/"FALSE". I don't know how to convert those on output in sqlite. For my app, I just hard-coded them, and this worked:
Code:
   sqlite3 -separator '    ' $HOME/.mozilla/firefox/$PROFILE.default/cookies.sqlite 'select host, "TRUE", path, "FALSE", expiry, name, value from moz_cookies' > cookies.txt
(Again, that separator is a tab character.)
 
Old 05-25-2009, 02:26 AM   #9
koyeung
LQ Newbie
 
Registered: May 2009
Posts: 2

Rep: Reputation: 0
you may try this script: (passing $HOME/.mozilla/firefox/$PROFILE.default/cookies.sqlite as the 1st parameter)

Quote:
#!/bin/bash
#

sqlite3 $1 <<EOF
.mode tabs
.header off
select host as domain,
case substr(host,1,1)='.' when 0 then 'FALSE' else 'TRUE' end as flag,
path,
case isSecure when 0 then 'FALSE' else 'TRUE' end as secure,
expiry as expiration, name, value from moz_cookies;

EOF

Last edited by koyeung; 05-25-2009 at 02:29 AM.
 
Old 08-11-2009, 09:04 PM   #10
allasso
Member
 
Registered: Oct 2003
Distribution: debian
Posts: 35

Rep: Reputation: 15
I tried the python script, but get this message:

Traceback (most recent call last):
File "./exp_ff_cky.py", line 21, in ?
import sqlite3 as db
ImportError: No module named sqlite3

sqlite3 is installed on my computer...

???
 
Old 08-12-2009, 12:16 AM   #11
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
You probably have to install a python module (or whatever it is called) to support sqlite3 in python.

http://www.sqlite.org/cvstrac/wiki?p=SqliteWrappers ; search for python
 
Old 03-14-2011, 03:19 AM   #12
ikarib
LQ Newbie
 
Registered: Mar 2011
Posts: 1

Rep: Reputation: 0
Use this statement
Code:
echo ".mode tabs
select host, case when host glob '.*' then 'TRUE' else 'FALSE' end, path,
case when isSecure then 'TRUE' else 'FALSE' end, expiry, name, value
from moz_cookies;" | sqlite3 ~/.mozilla/firefox/*.default/cookies.sqlite

Last edited by ikarib; 03-14-2011 at 03:23 AM.
 
Old 10-23-2012, 05:29 AM   #13
cooltra
LQ Newbie
 
Registered: Oct 2012
Posts: 4

Rep: Reputation: Disabled
Quote:
Originally Posted by ikarib View Post
Use this statement
Code:
echo ".mode tabs
select host, case when host glob '.*' then 'TRUE' else 'FALSE' end, path,
case when isSecure then 'TRUE' else 'FALSE' end, expiry, name, value
from moz_cookies;" | sqlite3 ~/.mozilla/firefox/*.default/cookies.sqlite
I get this Err:
Code:
Error: near line 2: file is encrypted or is not a database
?
 
Old 10-24-2012, 06:42 AM   #14
koyeung
LQ Newbie
 
Registered: May 2009
Posts: 2

Rep: Reputation: 0
you need to locate the cookies.sqlite properly first and replace "~/.mozilla/firefox/*.default/cookies.sqlite" by the actual path to the file
 
Old 10-25-2012, 12:35 AM   #15
cooltra
LQ Newbie
 
Registered: Oct 2012
Posts: 4

Rep: Reputation: Disabled
Quote:
you need to locate the cookies.sqlite properly first and replace "~/.mozilla/firefox/*.default/cookies.sqlite" by the actual path to the file
I did, but that error again:

Code:
cool@TRA:~$ echo ".mode tabs
> select host, case when host glob '.*' then 'TRUE' else 'FALSE' end, path,
> case when isSecure then 'TRUE' else 'FALSE' end, expiry, name, value
> from moz_cookies;" | sqlite3 /home/cool/.mozilla/firefox/cyote601.default/cookies.sqlite
Error: near line 2: file is encrypted or is not a database

Last edited by cooltra; 10-25-2012 at 12:58 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wget and Session Cookies mortrek Linux - Software 0 10-20-2006 04:44 PM
Where does lynx or firefox store cookies? stormrider_may Linux - Software 3 01-23-2006 06:00 PM
Konqueror / FireFox Cookies Vampir3 Linux - Software 4 12-16-2005 06:49 PM
modifying cookies in firefox pepisfree Linux - Software 2 08-25-2004 05:35 AM
mozilla firefox and cookies wrongman Linux - Software 1 05-11-2004 06:03 AM


All times are GMT -5. The time now is 09:25 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration