mIRC Home    About    Download    Register    News    Help

Print Thread
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.

Joined: Nov 2009
Posts: 295
P
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.
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.

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Try grab cookies from the page instead.

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.

Joined: Sep 2005
Posts: 2,881
H
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

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

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

Joined: Sep 2005
Posts: 2,881
H
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.


Link Copied to Clipboard