[Python] Extract Firefox cookies | Extraire les cookies de Firefox [Python] Extract Firefox cookies | Extraire les cookies de Firefox | Scripts | Codes

Scripts | Codes

All languages in three languages :-)


Permet de récupérer les cookies d'un site dans Firefox...
Utilisation:
- D'abord l'enregistrer sous un fichier appelé par exemple cooky.py
- Modifier dans les deux lignes suivantes:
cookiedb = '{$HOME}/.mozilla/firefox/vkuuxfit.default/cookies.sqlite'
targetfile = '{$HOME}/Bureau/cookies.txt'
- {$HOME} par le chemin vers votre dossier personnel : par exemple pour moi /home/ubu
- le nom un peu bizzare "vkuuxfit.default" par celui que vous trouverez dans le repertoire de ff, c-à-d ici : {$HOME}/.mozilla/firefox , normalement il ne devrait y'en avoir qu'un seul, celui finissant par "default" sinon si vous avez crée d'autres profiles, mettre le nom du répertoire du profile par lequel vous vous être connécté au site que vous voulez télécharger (par login et pwd) ... vous devriez facilement reconnaitre le dossier, car son nom finit par ".nom_du_profile".
Si vous voulez changer le nom du repertoire où sera stocké le fichier cookies.txt libre à vous.
- Exécuter le script avec le nom du site en premier argument, par exemple je veux récupérer les cookies du site "siteduzero.com" je tape: python cooke.py siteduzero.com
et j'aurais un fichier cookies.txt comme ceci :
-----------------------------------------------------
www.siteduzero.com TRUE / FALSE 1279648744 pseudo ubu
www.siteduzero.com TRUE / FALSE 1279648744 pass 8da0432739423d4ab36c3108a3abahc0187e7c27
www.siteduzero.com TRUE / FALSE 1279648744 hash 02af28288e9c0747be5402f48fg17788863bf423
www.siteduzero.com TRUE / FALSE 1279648744 mid2 11569111567
-----------------------------------------------------
Ce qui veut dire que l'on a les 4 variables avec les valeurs:
pseudo=ubu
pass=8da0432739423d4ab36c3108a3abahc0187e7c27
hash=02af28288e9c0747be5402f48fg17788863bf423
mid2=115691115677

To retrieve cookies of a site in Firefox ...
Usage: 
- First, save it under a file called eg. cooky.py 
- Modify the following two lines: 
cookiedb = '$(HOME)/.mozilla/firefox/vkuuxfit.default/cookies.sqlite' 
targetfile = '$(HOME)/Desktop/cookies.txt' 
- $(HOME) with the path to your home directory: for example for me /home/ubu 
- The name a bit weired "vkuuxfit.default" by the one you found in the repertoire of ff, ie here: $ (HOME)/.mozilla/firefox, you should find only one, the one ending with the string "default", if not you probalby created some other profiles, put the name of the directory of the profile which you'll use to be connected to the site. You should easily recognize the file because its name ends with ".name_of_profile. 
If you want to rename the directory where the file will be stored cookies.txt free to you. 
- Now to run the script: 
- Run the script with the name of the site as a first argument, for example I want to retrieve cookies from the site "siteduzero.com" I type: python cooky.py siteduzero.com 
and I would have a cookies.txt file like this: 
------------------------------------------------------ 
www.siteduzero.com TRUE / FALSE 1279648744 nickname ubu 
www.siteduzero.com TRUE / FALSE 1279648744 pass 8da0432739423d4ab36c3108a3abahc0187e7c27 
www.siteduzero.com TRUE / FALSE 1279648744 hash 
------------------------------------------------------
This means that we have the 4 variables with values:
nickname = ubu
pass = 8da0432739423d4ab36c3108a3abahc0187e7c27
hash = 02af28288e9c0747be5402f48fg17788863bf423
Mid2 = 115,691,115,677

لإستخراج ملفات تعريف الارتباط Cookies لموقع ما في فايرفوكس...

أولا احفظه تحت ملف مثلا cooky.py
ثانيا تعديل السطرين التاليين :
cookiedb = '{$HOME}/.mozilla/firefox/vkuuxfit.default/cookies.sqlite'

targetfile = '{$HOME}/Bureau/cookies.txt'
حيث تعوض $HOME  بمسار ملفك الشخصي و vkuuxfit بإسم ملف Firefox 
ثالثا تشغيل البرنامج النصي python cooky.py mysite.com
نتحصل على ملف cookies.txt

Open in a new window
#!/usr/bin/python
import sqlite3 as db
import sys
cookiedb = '{$HOME}/.mozilla/firefox/vkuuxfit.default/cookies.sqlite'
targetfile = '{$HOME}/Bureau/cookies.txt'
what = sys.argv[1]
connection = db.connect(cookiedb)
cursor = connection.cursor()
contents = "host, path, isSecure, expiry, name, value"
cursor.execute("SELECT " +contents+ " FROM moz_cookies WHERE host LIKE '%" 
+what+ "%'")
file = open(targetfile, 'w')
index = 0
for row in cursor.fetchall():
file.write("%s\tTRUE\t%s\t%s\t%d\t%s\t%s\n" % (row[0], row[1],
str(bool(row[2])).upper(), row[3], str(row[4]), str(row[5])))
index += 1
file.close()
connection.close()
print "Keywords: %s" % what
print "Exported: %d" % index

0 commentaires

Post a Comment

Subscribe to: Post Comments (Atom)
attendez....