mIRC Homepage
Posted By: Onions Fetching cookies from firefox? - 07/06/11 11:11 AM
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.
Posted By: pball Re: Fetching cookies from firefox? - 07/06/11 11:42 AM
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.
Posted By: Onions Re: Fetching cookies from firefox? - 08/06/11 10:01 AM
I honestly don't know how that would help me.
Posted By: DJ_Sol Re: Fetching cookies from firefox? - 08/06/11 12:32 PM
Try grab cookies from the page instead.
Posted By: Onions Re: Fetching cookies from firefox? - 09/06/11 06:50 AM
Grabbing cookies from a page and from firefox is entirely different, that doesn't help me either.
Posted By: hixxy Re: Fetching cookies from firefox? - 13/06/11 12:30 PM
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
Posted By: Onions Re: Fetching cookies from firefox? - 16/06/11 11:43 AM
tyvm hixxy.

Wow, that DLL Script is huge >.<

Going to attempt to have a look, will post here when I have issues wink
Posted By: Onions Re: Fetching cookies from firefox? - 18/06/11 05:59 AM
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
Posted By: hixxy Re: Fetching cookies from firefox? - 20/06/11 01:45 PM
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.
© mIRC Discussion Forums