-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapplication.py
72 lines (55 loc) · 1.82 KB
/
application.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import os.path
from shutil import copy
import sqlite3
#from datetime import datetime
import win32crypt
'''
Extract and decrypt cookie information from
Chrome cookie databases on Windows.
Initial code inspiration from Jordan Wright <jordan-wright.github.io>
March 9 2017 '''
def getCookieDB():
# Fetch the cookie DB and copy to local folder.
# This helps avoid access issues due to DB locking while Chrome is open.
userhome = os.path.expanduser('~')
destination = os.path.dirname(os.path.realpath(__file__))
filePath = os.path.normpath(os.path.join(
userhome, 'AppData\\Local\\Google\\Chrome'
'\\User Data\\Default\\cookies'))
copy(filePath, destination)
getCookieDB()
# Connect to the Database
conn = sqlite3.connect('cookies')
cursor = conn.cursor()
# Get the results
cursor.execute('''
SELECT name,
encrypted_value,
host_key,
path,
secure,
httponly,
creation_utc,
expires_utc
FROM cookies
ORDER BY host_key
''')
with open('export.txt', 'w') as f:
for result in cursor.fetchall():
f.write("Name: {}\n".format(result[0]))
f.write("Content: {}\n".format(
win32crypt.CryptUnprotectData(result[1])[1].decode()))
f.write("Domain: {}\n".format(result[2]))
f.write("Path: {}\n".format(result[3]))
if result[4] == 1:
f.write("Send for: Secure connections only\n")
else:
f.write("Send for: Any kind of connection\n")
if result[5] == 1:
f.write("Accessible to script: Yes\n")
else:
f.write("Accessible to script: No (HttpOnly)\n")
# To do: Convert UTC to naive datetime at minimum.
f.write("Created: {}\n".format(result[6]))
f.write("Expires: {}\n".format(result[7]))
f.write("\n\n")