Skip to content

Instantly share code, notes, and snippets.

@AmmarHaddadi
Forked from pich4ya/Swoopy.py
Created February 21, 2023 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AmmarHaddadi/40af9aac0ae89818173fc0cda6d6253e to your computer and use it in GitHub Desktop.
Save AmmarHaddadi/40af9aac0ae89818173fc0cda6d6253e to your computer and use it in GitHub Desktop.
Decrypt Chrome/Opera Saved Passwords - 2018
# https://geekswipe.net/technology/computing/swoop-chrome-passwords-decrypt-with-python/
# https://github.com/karthikeyankc/Swoopy/blob/master/Swoopy.py
# INSTALL: https://github.com/mhammond/pywin32/releases
import os
import sqlite3
import win32crypt
#path to user's login data
# For Chrome:
#data_path = os.path.expanduser('~')+"\AppData\Local\Google\Chrome\User Data\Default"
# For Opera:
data_path = os.path.expanduser('~')+"\AppData\Roaming\Opera Software\Opera Stable"
login_db = os.path.join(data_path, 'Login Data')
#db connect and query
c = sqlite3.connect(login_db)
cursor = c.cursor()
select_statement = "SELECT origin_url, username_value, password_value FROM logins"
cursor.execute(select_statement)
login_data = cursor.fetchall()
#URL: credentials dictionary
credential = {}
#decrytping the password
for url, user_name, pwd, in login_data:
pwd = win32crypt.CryptUnprotectData(pwd, None, None, None, 0) #This returns a tuple description and the password
credential[url] = (user_name, pwd[1])
#writing to a text file (CAUTION: Don't leave this text file around!)
#prompt = raw_input("[.] Are you sure you want to write all this sensitive data to a text file? \n[.] or \n[>] ")
#if prompt == 'y':
with open('pwd.txt', 'w') as f:
for url, credentials in credential.iteritems():
if credentials[1]:
f.write("\n"+url+"\n"+credentials[0].encode('utf-8')+ " | "+credentials[1]+"\n")
else:
f.write("\n"+url+"\n"+"USERNAME NOT FOUND | PASSWORD NOT FOUND \n")
print "[.] Successfully written to pwd.txt!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment