Reputation: 127
I've written a script to decrypt old passwords and accounts that I can't access because I can't access my old email (again because I can't remember the passwords haha).
import os
import sqlite3
import win32crypt
import sys
try:
path = sys.argv[1]
except IndexError:
for w in os.walk(os.getenv('USERPROFILE')):
if 'Chrome' in w[1]:
path = str(w[0]) + '/Chrome/User Data/Default/Login Data'
try:
print ('[+] Opening ' + path)
conn = sqlite3.connect(path)
cursor = conn.cursor()
except Exception as e:
print ('[-] %s' % (e))
sys.exit(1)
# Get the results
try:
cursor.execute('SELECT action_url, username_value, password_value FROM logins')
except Exception as e:
print ('[-] %s' % (e))
sys.exit(1)
data = cursor.fetchall()
Everything is fine up to here.
for result in data:
try:
password = win32crypt.CryptUnprotectData(result[2], None)
except Exception as e:
print('[-] %s' % (e))
pass
if password:
print("[+] URL: {} Username: {} Password: {}".format(result[0], result[1], password))
else: print("Unable to extract data")
I get this error: (-2146893813, 'CryptProtectData', 'Key not valid for use in specified state.')
Thanks to gilliduck for pointing out my typo!
Upvotes: 0
Views: 3209