Code Monkey home page Code Monkey logo

chrome_password_grabber's Introduction

Chrome-Password-Grabber

Get unencrypted 'Saved Password' from Google Chrome

Introduction

Like other browsers Chrome also has built-in login password manager functionality which keeps track of the login secrets of all visited websites. Whenever user logins to any website, he/she will be prompted to save the credentials for later use and if user chooses so, then the username & passwords will be stored in internal login database. So next time onwards whenever user visits that website, he/she will be automatically logged in using these stored credentials which saves hassle of entering the credentials every time.

Chrome stores all the sign-on secrets into the internal database file called 'Web data' in the current user profile folder. Newer version has moved the login passwords related database into new file named 'Login Data'.This database file is in SQLite format and contains number of tables storing different kind of data such as auto complete, search keyword, ie7logins etc in addition to login secrets.

The logins table mainly contains the information about sign-on secrets such as website URL, username, password fields etc. All this information is stored in the clear text except passwords which are in encrypted format.

Windows Implementation

Google Chrome encrypt the password with the help of CryptProtectData function, built into Windows. Now while this can be a very secure function using a triple-DES algorithm and creating user-specific keys to encrypt the data, it can still be decrypted as long as you are logged into the same account as the user who encrypted it.The CryptProtectData function has a twin, who does the opposite to it; CryptUnprotectData, which... well you guessed it, decrypts the data. And obviously this is going to be very useful in trying to decrypt the stored passwords.

Mac/Linux Implementation

Encryption Scheme: AES-128 CBC with a constant salt and constant iterations. The decryption key is a PBKDF2 key generated with the following:

  • salt is b'saltysalt'
  • key length is 16
  • iv is 16 bytes of space b' ' * 16
  • on Mac OSX:
    • password is in keychain under Chrome Safe Storage
      • I use the excellent keyring package to get the password
      • You could also use bash: security find-generic-password -w -s "Chrome Safe Storage"
    • number of iterations is 1003
  • on Linux:
    • password is peanuts
    • number of iterations is 1

Python Implementation (Working)

Usage

>>> from chrome import Chrome
>>> chrome_pwd = Chrome()
>>> chrome_pwd.get_login_db
'/Users/x899/Library/Application Support/Google/Chrome/Default/'
>>> chrome_pwd.get_password(prettyprint=True)
{
	"data": [
		{
			"url": "https://x899.com/",
			"username": "admin",
			"password": "secretP@$$w0rD"
		},
		{
			"url": "https://accounts.google.com/",
			"username": "[email protected]",
			"password": "@n04h3RP@$$m0rC1"
		}
	]
}

Contribute

Feel free to contribute. Please Follow PEP8 Guidelines.

TO DO:

  • Cookie support
  • Updating database password directly

chrome_password_grabber's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chrome_password_grabber's Issues

Some password cannot read

"password": "sY/f\f\rr"\n
"password": "iL\u000b<*ood"\n
"password": "sY/f\f\rr"\n
"password": "R/+ed0H"\n

some password like this.... it's not actual password...

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x86 in position 0: invalid start byte

larry@LarryDeMBP chrome_password_grabber-master % python chrome.py

/Users/larry/Library/Application Support/Google/Chrome/Default/
Traceback (most recent call last):
File "/Users/larry/Downloads/chrome_password_grabber-master/chrome.py", line 158, in
main()
File "/Users/larry/Downloads/chrome_password_grabber-master/chrome.py", line 154, in main
chrome_pwd.get_password(prettyprint=True)
File "/Users/larry/Downloads/chrome_password_grabber-master/chrome.py", line 134, in get_password
_passwd = self.chrome_os.decrypt_func(result[2])
File "/Users/larry/Downloads/chrome_password_grabber-master/chrome.py", line 50, in decrypt_func
return decrypted.strip().decode('utf8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x86 in position 0: invalid start byte

even I configured utf8 still get this error....but I checked the code line #50, it has utf8, why still has this error??

Error when itry open password in lInux from windows machine

Hello.
I reinstall my system to debian. When i copy files from my old system. And after i try use your script it print error
File "/home/shor/chrome.py", line 157, in <module> main() File "/home/shor/chrome.py", line 153, in main chrome_pwd.get_password(prettyprint=True) File "/home/shor/chrome.py", line 133, in get_password _passwd = self.chrome_os.decrypt_func(result[2]) File "/home/shor/chrome.py", line 99, in decrypt_func decrypted = cipher.decrypt(enc_passwd) File "/home/shor/.local/lib/python3.9/site-packages/Crypto/Cipher/_mode_cbc.py", line 246, in decrypt raise ValueError("Data must be padded to %d byte boundary in CBC mode" % self.block_size) ValueError: Data must be padded to 16 byte boundary in CBC mode

DBUS error after installing dependencies

Hi all!

I have an issue after the installation of dependencies :

  • SecretStorage==3.3.0
  • pycrypto=2.6.1 ) then running

The error concern the env var called DBUS_SESSION_BUS_ADDRESS

I tried without SUDO:

_Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/secretstorage/init.py", line 72, in dbus_init
connection = open_dbus_connection()
File "/usr/lib/python3/dist-packages/jeepney/io/blocking.py", line 255, in open_dbus_connection
conn = DBusConnection(sock)
File "/usr/lib/python3/dist-packages/jeepney/io/blocking.py", line 68, in init
hello_reply = self.bus_proxy.Hello()
File "/usr/lib/python3/dist-packages/jeepney/io/blocking.py", line 223, in inner
return self._connection.send_and_get_reply(
File "/usr/lib/python3/dist-packages/jeepney/io/blocking.py", line 134, in send_and_get_reply
self.send_message(message, serial=serial)
File "/usr/lib/python3/dist-packages/jeepney/io/blocking.py", line 83, in send
self.sock.sendall(data)
BrokenPipeError: [Errno 32] Broken pipe

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/scripts/chrome_password_grabber/./decrypt_chrome_pass_ulti.py", line 2, in
chrome_pwd = Chrome()
File "/scripts/chrome_password_grabber/chrome.py", line 113, in init
self.chrome_os = ChromeLinux()
File "/scripts/chrome_password_grabber/chrome.py", line 79, in init
bus = secretstorage.dbus_init()
File "/usr/lib/python3/dist-packages/secretstorage/init.py", line 80, in dbus_init
raise SecretServiceNotAvailableException(str(ex)) from ex
secretstorage.exceptions.SecretServiceNotAvailableException: [Errno 32] Broken pipe_

Then I tried wiith SUDO:

_sudo python3 ./decrypt_chrome_pass_ulti.py
sudo: impossible de résoudre l'hôte Parrot: Nom ou service inconnu
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/secretstorage/init.py", line 72, in dbus_init
connection = open_dbus_connection()
File "/usr/lib/python3/dist-packages/jeepney/io/blocking.py", line 243, in open_dbus_connection
bus_addr = get_bus(bus)
File "/usr/lib/python3/dist-packages/jeepney/bus.py", line 53, in get_bus
return find_session_bus()
File "/usr/lib/python3/dist-packages/jeepney/bus.py", line 42, in find_session_bus
addr = os.environ['DBUS_SESSION_BUS_ADDRESS']
File "/usr/lib/python3.9/os.py", line 679, in getitem
raise KeyError(key) from None
KeyError: 'DBUS_SESSION_BUS_ADDRESS'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/scripts/chrome_password_grabber/./decrypt_chrome_pass_ulti.py", line 2, in
chrome_pwd = Chrome()
File "/scripts/chrome_password_grabber/chrome.py", line 113, in init
self.chrome_os = ChromeLinux()
File "/scripts/chrome_password_grabber/chrome.py", line 79, in init
bus = secretstorage.dbus_init()
File "/usr/lib/python3/dist-packages/secretstorage/init.py", line 78, in dbus_init
raise SecretServiceNotAvailableException(reason) from ex
secretstorage.exceptions.SecretServiceNotAvailableException: Environment variable DBUS_SESSION_BUS_ADDRESS is unset_

error when running

jason@archlinux ~/.config/google-chrome/Default $ python getpasswords.py
/home/jason/.config/google-chrome/Default/
Traceback (most recent call last):
File "/home/jason/.config/google-chrome/Default/getpasswords.py", line 157, in
main()
File "/home/jason/.config/google-chrome/Default/getpasswords.py", line 153, in main
chrome_pwd.get_password(prettyprint=True)
File "/home/jason/.config/google-chrome/Default/getpasswords.py", line 133, in get_password
_passwd = self.chrome_os.decrypt_func(result[2])
File "/home/jason/.config/google-chrome/Default/getpasswords.py", line 98, in decrypt_func
cipher = aes.new(self.key, aes.MODE_CBC, IV=initialization_vector)
File "/home/jason/.local/lib/python3.10/site-packages/Crypto/Cipher/AES.py", line 95, in new
return AESCipher(key, *args, **kwargs)
File "/home/jason/.local/lib/python3.10/site-packages/Crypto/Cipher/AES.py", line 59, in init
blockalgo.BlockAlgo.init(self, _AES, key, *args, **kwargs)
File "/home/jason/.local/lib/python3.10/site-packages/Crypto/Cipher/blockalgo.py", line 141, in init
self._cipher = factory.new(key, *args, **kwargs)
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

???

-db

Outdated README file?

The first line of how to use says

>>> from chrome_passwd import ChromePasswd

by the file is not called chrome_password. Changing it gives

>>> from chrome import ChromePasswd
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'ChromePasswd' from 'chrome' (/tmp/chrome_password_grabber/chrome.py)

The .py file on that repository has no ChromePasswd Method or Class.

So there a lot of changes must have happened since the README was last updated?

Different chrome versions, the path is different on windows

it's somme not perfect in windows. beacuase i use the dev chrome and whitch path like this :
C:\Users\mrxn\AppData\Local\Google\chrome dev\User Data\Default\
and the stable chrome version path is:
C:\Users\mrxn\AppData\Local\Google\chrome\User Data\Default\
that's all
thanks.

Exception has occurred: error (87, 'CryptProtectData', 'The parameter is incorrect.')

Exception has occurred: error
(87, 'CryptProtectData', 'The parameter is incorrect.')

File "C:\Users*\Desktop\Coding\Garbage Coding\chrome.py", line 67, in decrypt_func
data = win32crypt.CryptUnprotectData(enc_passwd, None, None, None, 0)
File "C:\Users*
\Desktop\Coding\Garbage Coding\chrome.py", line 130, in get_password
_passwd = self.chrome_os.decrypt_func(result[2])
File "C:\Users**\Desktop\Coding\Garbage Coding\pog.py", line 5, in
chrome_pwd.get_password(prettyprint=True)

Decode Error

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xda in position 1: invalid continuation byte

Happened after changing the location to the correct folder.

ModuleNotFoundError: No module named 'Crypto'

For some reason it doesn't detect that Crypto is installed.

Using Fedora Linux 32 64bit.

# pip install Crypto
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip install --user` instead.
Collecting Crypto
  Downloading https://files.pythonhosted.org/packages/fc/bb/0b812dc02e6357606228edfbf5808f5ca0a675a84273578c3a199e841cd8/crypto-1.4.1-py2.py3-none-any.whl
Collecting shellescape
  Downloading https://files.pythonhosted.org/packages/d0/f4/0081137fceff5779cd4205c1e96657e41cc2d2d56c940dc8eeb6111780f7/shellescape-3.8.1-py2.py3-none-any.whl
Collecting Naked
  Downloading https://files.pythonhosted.org/packages/02/36/b8107b51adca73402ec1860d88f41d958e275e60eea6eeaa9c39ddb89a40/Naked-0.1.31-py2.py3-none-any.whl (590kB)
     |████████████████████████████████| 593kB 13.9MB/s 
Requirement already satisfied: requests in /usr/lib/python3.8/site-packages (from Naked->Crypto) (2.22.0)
Requirement already satisfied: pyyaml in /usr/local/lib64/python3.8/site-packages (from Naked->Crypto) (5.3.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/lib/python3.8/site-packages (from requests->Naked->Crypto) (3.0.4)
Requirement already satisfied: idna<2.9,>=2.5 in /usr/lib/python3.8/site-packages (from requests->Naked->Crypto) (2.8)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/lib/python3.8/site-packages (from requests->Naked->Crypto) (1.25.7)
Installing collected packages: shellescape, Naked, Crypto
Successfully installed Crypto-1.4.1 Naked-0.1.31 shellescape-3.8.1
/tmp/chrome_password_grabber$ python
Python 3.8.6 (default, Sep 25 2020, 00:00:00) 
[GCC 10.2.1 20200723 (Red Hat 10.2.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> from chrome import Chrome
>>> chrome_pwd = Chrome()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/chrome_password_grabber/chrome.py", line 113, in __init__
    self.chrome_os = ChromeLinux()
  File "/tmp/chrome_password_grabber/chrome.py", line 89, in __init__
    kdf = import_module('Crypto.Protocol.KDF')
  File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'Crypto'
>>> 

Add Chromium for Linux

In my case the folder is /home/yaron/.config/chromium/Default/Login Data instead of google-chrome.

Help me !

1.-) Im new at python and i don't know how to run this project.
2.-) Please tell me process i have to do.
3.-) I have Login Data file its possible for grabbing passwords?

Broken pipe error

>>> from chrome import Chrome
>>> c = Chrome()
Traceback (most recent call last):
  File "/usr/local/lib/python3/site-packages/secretstorage/__init__.py", line 73, in dbus_init
    connection = open_dbus_connection()
  File "/usr/local/lib/python3/site-packages/jeepney/io/blocking.py", line 344, in open_dbus_connection
    conn = DBusConnection(sock, enable_fds)
  File "/usr/local/lib/python3/site-packages/jeepney/io/blocking.py", line 139, in __init__
    hello_reply = self.bus_proxy.Hello()
  File "/usr/local/lib/python3/site-packages/jeepney/io/blocking.py", line 279, in inner
    return unwrap_msg(self._connection.send_and_get_reply(
  File "/usr/local/lib/python3/site-packages/jeepney/io/blocking.py", line 193, in send_and_get_reply
    self.send_message(message, serial=serial)
  File "/usr/local/lib/python3/site-packages/jeepney/io/blocking.py", line 154, in send
    self.sock.sendall(data)
BrokenPipeError: [Errno 32] Broken pipe

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/teacher/.config/chromium/Default/chrome_password_grabber/chrome.py", line 114, in __init__
    self.chrome_os = ChromeLinux()
  File "/home/teacher/.config/chromium/Default/chrome_password_grabber/chrome.py", line 80, in __init__
    bus = secretstorage.dbus_init()
  File "/usr/local/lib/python3/site-packages/secretstorage/__init__.py", line 81, in dbus_init
    raise SecretServiceNotAvailableException(str(ex)) from ex
secretstorage.exceptions.SecretServiceNotAvailableException: [Errno 32] Broken pipe

Linux KDE, x86_64 GNU/Linux
i'm trying to do it via ssh
Python 3.9.6

Standalone use chrome_password_grabber.py ?

Hi.

How to standalone use chrome_password_grabber.py ?

I've never used python, and I don't know how to use this code. Is it possible to pass the path to the database to the script

chrome_password_grabber.py ./Login\ Data

and get the passwords at the output ?

Description of Linux Implementation is Wrong

Hi,
the following description of the Linux implementation is not true:

on Linux:
password is peanuts

The implementation depends on the used password store (option: --password-store=<basic|gnome|kwallet>). The password is peanuts only if the basic store is used. In default, it detects automatically if KWallet or Gnome keyring is available and storing a random password there.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.