modify windows paths, untested!

This commit is contained in:
ccppi 2024-08-23 12:22:07 +02:00
parent 536b4d23f8
commit c35f43ce8a

View File

@ -8,6 +8,7 @@ import sqlite3
import shutil
from time import sleep
import manipulateString as ms
DEBUG = True
def log(*s):
if DEBUG:
@ -29,13 +30,17 @@ def findDefaultProfile(path):
return target
def getCookiesFromBrowser(url):
homePath = os.path.expanduser('~')
cookiePath = homePath + "/.mozilla/firefox/" + findDefaultProfile(homePath + "/.mozilla/firefox/") + "/cookies.sqlite"
tmpPath = "/tmp/cookies.sqlite"
DBFILE = "../db/sqlite3.db"
winFirefoxPath = f"""C:\\Program Files\\Mozilla Firefox\\firefox.exe"""
wintTmpPath = tempfile.gettempdir()
#workaround for loked database
if os.name == 'posix':
homePath = os.path.expanduser('~')
cookiePath = homePath + "/.mozilla/firefox/" + findDefaultProfile(homePath + "/.mozilla/firefox/") + "/cookies.sqlite"
tmpPath = "/tmp/cookies.sqlite"
if os.name == 'nt':
appdata = os.getenv('APPDATA')
winCookiePath = appdata + "\\Mozilla\\Firefox\\Profiles\\" + findDefaultProfile(appdata + "\\Mozilla\\Firefox\\Profiles\\") + "cookies.sqlite"
winFirefoxPath = "C:\\Program Files\\Mozilla Firefox\\firefox.exe"
tmpPath = tempfile.gettempdir() + "\\cookies.sqlite"
tries=0
cookie = ''
rows = [0]
@ -44,10 +49,7 @@ def getCookiesFromBrowser(url):
if os.name == 'posix':
shutil.copyfile(cookiePath,tmpPath)
elif os.name == 'nt':
appdata = os.getenv('APPDATA')
winCookiePath = appdata + "\\Mozilla\\Firefox\\Profiles\\" + profile + "cookies.sqlite"
shutil.copyfile(winCookiePath,wintTmpPath)
shutil.copyfile(winCookiePath,tmpPath)#workaround for loked database
with sqlite3.connect(tmpPath) as connection:
cmd_read_cookies = f"""SELECT name,value FROM moz_cookies WHERE host like ?;"""
print(cmd_read_cookies)