GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing thepythoncode.com — How to Extract Chrome Passwords in Python - The Python Code Struggling with multiple programming languages? No worries. Our Code Converter has got you covered. Give it a go! Extracting saved passwords in the most popular browser is a useful and handy forensic task, as Chrome saves passwords locally in an SQLite database. However, this can be time-consuming when doing it manually. Since Chrome saves a lot of your browsing data locally on your disk, In this tutorial, we will write Python code to extract saved passwords in Chrome on your Windows machine. We will also make a quick script to protect ourselves from such attacks. Related: Build 35+ Ethical Hacking Scripts & Tools with Python EBook To get started, let's install the required libraries:
Open up a new Python file, and import the necessary modules:
Before going straight into extracting chrome passwords, we need to define some useful functions that will help us in the main function:
Get: Build 35+ Ethical Hacking Scripts & Tools with Python EBook get_chrome_datetime() function is responsible for converting the Chrome date format into a human-readable date-time format. get_encryption_key() function extracts and decodes the AES key that was used to encrypt the passwords that are stored in the decrypt_password() takes the encrypted password and the AES key as arguments and returns a decrypted version of the password. Below is the main function:
Related: How to Make a Password Generator in Python. First, we get the encryption key using the previously defined get_encryption_key() function, then we copy the SQLite database (located at After that, we make a select query to the logins table and iterate over all login rows. We also decrypt each password and reformat the Finally, we print the credentials and remove the database copy from the current directory. Let's call the main function:
The output should be something like this format (obviously, I'm sharing fake credentials):
Great, now you're aware that a lot of sensitive information is in your machine and is easily readable using scripts like this one. Disclaimer: Please run this script on your machine or on a machine you have permission to access. We do not take any responsibility for any misuse. Related: How to Use MySQL Database in Python. Deleting PasswordsAs you just saw, saved passwords on Chrome are quite dangerous to leave them there. Now you're maybe wondering how we can protect ourselves from malicious scripts like this. In this section, we will write a script to access that database and delete all rows from
This will require you to close the Chrome browser and then run it. Here is my output:
Once you open Chrome this time, you'll notice that auto-complete on login forms is not there anymore. Run the first script as well, and you'll notice it outputs nothing, so we have successfully protected ourselves from this! ConclusionIn this tutorial, you learned how to write a Python script to extract Chrome passwords on Windows, as well as delete them to prevent malicious users from being able to access them. Note that in this tutorial, we have only talked about If you want to extract Chrome cookies, this tutorial walks you through extracting and decrypting Chrome cookies in a similar way. For example, there is These are all SQLite databases that you can access. Make sure you make a copy and then open a database, so you won't close Chrome whenever you want to access it. Alright, we are done. Check the complete code here. Finally, in our Ethical Hacking with Python EBook, we have built over 35 hacking tools and programs from scratch using Python! Check it out here if you're interested! Learn also: How to Crack PDF Files in Python. Happy Hacking ♥ Found the article interesting? You'll love our Python Code Generator! Give AI a chance to do the heavy lifting for you. Check it out!
Sharing is caring!
Read alsoHow to Extract Chrome Cookies in PythonLearn how to extract Google Chrome browser saved cookies and decrypt them on your Windows machine in Python.
How to Brute Force ZIP File Passwords in PythonLearn how to crack zip file passwords using dictionary attack in Python using the built-in zipfile module. How to Brute Force FTP Servers in PythonLearning how to crack FTP servers using dictionary attack (brute-forcing with a wordlist) with the help of ftplib module in Python. CommentsGot a coding query or need some guidance before you comment? Check out this Python Code Assistant for expert advice and handy tips. It's like having a coding tutor right in your fingertips! |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |