22import platform
33import sqlite3
44import subprocess
5+ from configparser import MissingSectionHeaderError
56from getpass import getuser
67from os import path , getenv
78from os .path import isdir
@@ -26,7 +27,7 @@ def get_cookie_firefox():
2627 os = platform .system ()
2728
2829 if os == 'Windows' :
29- appdata_dir = path .join (getenv ('APPDATA' ), 'Mozilla/Firefox' )
30+ appdata_dir = path .join (getenv ('APPDATA' ), 'Mozilla/Firefox' ). rstrip (). replace ( " \\ " , "/" )
3031 elif os == 'Linux' :
3132 if in_wsl (): # we are in linux subsystem
3233 print ('Detected Windows Subsystem for Linux' )
@@ -36,7 +37,7 @@ def get_cookie_firefox():
3637 hack_path = hack_path .rstrip ().replace ("\\ " , "/" ).replace ("C:" , "/mnt/c" )
3738 appdata_dir = path .join (hack_path , 'Mozilla/Firefox' )
3839 else :
39- appdata_dir = path .join ('/home/' , getuser (), '.mozilla/firefox' )
40+ appdata_dir = path .join ('/home/' , getuser (), '.mozilla/firefox' ). rstrip (). replace ( " \\ " , "/" )
4041 else :
4142 print ('Could not establish OS! Aborting cookie retrieval...' )
4243 return - 1
@@ -45,11 +46,14 @@ def get_cookie_firefox():
4546 print ('Firefox was not found on this system' )
4647 return - 1
4748
48- config_path = path .join (appdata_dir , 'profiles.ini' )
49+ config_path = path .join (appdata_dir , 'profiles.ini' ). rstrip (). replace ( " \\ " , "/" )
4950
50- config = configparser .ConfigParser ()
51- config .read (config_path )
52- database_path = path .join (appdata_dir , config ['Profile0' ]['Path' ], 'cookies.sqlite' )
51+ try :
52+ config = configparser .ConfigParser ()
53+ config .read (config_path )
54+ database_path = path .join (appdata_dir , config ['Profile0' ]['Path' ], 'cookies.sqlite' )
55+ except MissingSectionHeaderError :
56+ return - 1
5357
5458 # connect to cookie database and read cookie
5559 try :
0 commit comments