mIRC Home    About    Download    Register    News    Help

Print Thread
Fetching cookies from firefox? #232501 07/06/11 11:11 AM
Joined: Apr 2011
Posts: 14
O
Onions Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Apr 2011
Posts: 14
Is there any way to grab the cookies from firefox (running version 4)?

I've tried doing a while loop with $fread connecting to the file:
Code:
alias cookie_file return $gettok($mircdir,1- $+ $calc($count($mircdir,\) - 1),92) $+ \Mozilla\Firefox\ $+ $replace($readini($gettok($mircdir,1- $+ $calc($count($mircdir,\) - 1),92) $+ \Mozilla\Firefox\profiles.ini,Profile0,Path),/,\) $+ \cookies.sqlite

However I can't even view the whole file with that.

Re: Fetching cookies from firefox? [Re: Onions] #232502 07/06/11 11:42 AM
Joined: Nov 2009
Posts: 295
P
pball Offline
Fjord artisan
Offline
Fjord artisan
P
Joined: Nov 2009
Posts: 295
Best way I know of is to use something that shows http info when you visit a page. I use the addon HttpFox, it shows all the http header info, cookies, etc when you request a webpage.


http://scripting.pball.win
My personal site with some scripts I've released.
Re: Fetching cookies from firefox? [Re: Onions] #232534 08/06/11 10:01 AM
Joined: Apr 2011
Posts: 14
O
Onions Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Apr 2011
Posts: 14
I honestly don't know how that would help me.

Re: Fetching cookies from firefox? [Re: Onions] #232535 08/06/11 12:32 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Try grab cookies from the page instead.

Re: Fetching cookies from firefox? [Re: DJ_Sol] #232549 09/06/11 06:50 AM
Joined: Apr 2011
Posts: 14
O
Onions Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Apr 2011
Posts: 14
Grabbing cookies from a page and from firefox is entirely different, that doesn't help me either.

Re: Fetching cookies from firefox? [Re: Onions] #232622 13/06/11 12:30 PM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
First of all, please don't get your hopes up as I'm not offering you a working code example here, just pointing you in the right direction to get what you want :p

Your $cookie_file makes an assumption that the mIRC folder is in %appdata% but this isn't always the case. You should instead use a COM object to get the value of the %appdata% environment variable like so:

Code:
alias cookie_file {
  if (%ffcookies) return $v1
  var %object = appdata $+ $ticks, %ffdir, %result
  .comopen %object wscript.shell
  noop $com(%object,expandenvironmentstrings,3,bstr,% $+ appdata%\Mozilla\Firefox\profiles.ini)
  %ffdir = $com(%object).result
  %result = $+($nofile(%ffdir),$replace($readini(%ffdir,Profile0,Path),/,\),\cookies.sqlite)
  .comclose %object
  if ($isfile(%result)) { set %ffcookies %result }
  return %result
}


It only does the slow process of using $com once and then caches the value. All subsequent calls to $cookie_file just retrieve the cached value.

As for reading the file itself, you have two options that I can think of: -

1) Read this page thoroughly and write a script which reads the SQLite database. It's a very in-depth document explaining the format of an SQLite file. The database files are in a binary format, which is why simply looping with $fread() won't get you anywhere.

2) Download mIRC SQlite which is a DLL and can read from SQLite databases.

The second option will of course be much simpler. smile

Re: Fetching cookies from firefox? [Re: hixxy] #232692 16/06/11 11:43 AM
Joined: Apr 2011
Posts: 14
O
Onions Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Apr 2011
Posts: 14
tyvm hixxy.

Wow, that DLL Script is huge >.<

Going to attempt to have a look, will post here when I have issues wink

Re: Fetching cookies from firefox? [Re: Onions] #232730 18/06/11 05:59 AM
Joined: Apr 2011
Posts: 14
O
Onions Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Apr 2011
Posts: 14
Originally Posted By: Onions
tyvm hixxy.

Wow, that DLL Script is huge >.<

Going to attempt to have a look, will post here when I have issues wink

Code:
alias cookie_file {
  if (%ffcookies) return $v1
  var %object = appdata $+ $ticks, %ffdir, %result
  .comopen %object wscript.shell
  noop $com(%object,expandenvironmentstrings,3,bstr,% $+ appdata%\Mozilla\Firefox\profiles.ini)
  %ffdir = $com(%object).result
  %result = $+($nofile(%ffdir),$replace($readini(%ffdir,Profile0,Path),/,\),\cookies.sqlite)
  .comclose %object
  if ($isfile(%result)) { var %ffcookies %result }
  return %result
}
alias test_c {
  var %db = $sqlite_open(cookies.db)
  if (!%db) { echo -a failed opening db. | halt }
  var %x = $sqlite_exec_file(%db,$cookie_file)
  if (!%x) { echo -a Exec error: %sqlite_errstr | halt }
  var %sql = SELECT * FROM moz_cookies
  var %res = $sqlite_query(%db, %sql)
  if (%res) {
    echo -a Number of rows returned: $sqlite_num_rows(%res)
    sqlite_free %res
  }
  else echo -a Failed :(
  sqlite_close %db
}



Returns "Exec error: query not specified"

Why :s

Re: Fetching cookies from firefox? [Re: Onions] #232763 20/06/11 01:45 PM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Sorry I've never used the dll myself so I'm not sure, I just knew it existed! :P

You might wish to try emailing the author, I think his contact information is in the help file.