From 579477c6d14c12cc8a1fdf659e526d0d7b5cc4a0 Mon Sep 17 00:00:00 2001 From: Oleksii Shevchuk Date: Tue, 23 May 2017 22:55:07 +0300 Subject: [PATCH] Add support for plain-text Chrome passwords on Linux --- Linux/lazagne/config/manageModules.py | 2 + Linux/lazagne/softwares/browsers/chrome.py | 56 ++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 Linux/lazagne/softwares/browsers/chrome.py diff --git a/Linux/lazagne/config/manageModules.py b/Linux/lazagne/config/manageModules.py index 454f1ff7..ef45f756 100755 --- a/Linux/lazagne/config/manageModules.py +++ b/Linux/lazagne/config/manageModules.py @@ -5,6 +5,7 @@ # browsers from lazagne.softwares.browsers.mozilla import Mozilla from lazagne.softwares.browsers.opera import Opera +from lazagne.softwares.browsers.chrome import Chrome # sysadmin from lazagne.softwares.sysadmin.filezilla import Filezilla from lazagne.softwares.sysadmin.env_variable import Env_variable @@ -58,6 +59,7 @@ def get_modules(): Jitsi(), Mozilla(), Opera(), + Chrome(), Pidgin(), Shadow(), Aws(), diff --git a/Linux/lazagne/softwares/browsers/chrome.py b/Linux/lazagne/softwares/browsers/chrome.py new file mode 100644 index 00000000..944e8c49 --- /dev/null +++ b/Linux/lazagne/softwares/browsers/chrome.py @@ -0,0 +1,56 @@ +# For non-keyring storage + +from lazagne.config.constant import * +from lazagne.config.write_output import print_debug +from lazagne.config.moduleInfo import ModuleInfo +from lazagne.config import homes + +import sqlite3 +import tempfile + +class Chrome(ModuleInfo): + def __init__(self): + options = {'command': '-C', 'action': 'store_true', 'dest': 'chrome', 'help': 'chrome'} + ModuleInfo.__init__(self, 'chrome', 'browsers', options) + + def get_paths(self): + return homes.get(file=[ + '.config/google-chrome/Default/Login Data', + '.config/chromium/Default/Login Data' + ]) + + def get_logins(self, path): + try: + conn = sqlite3.connect(path) + except: + return + + cursor = conn.cursor() + + try: + cursor.execute('SELECT origin_url,username_value,password_value FROM logins') + for url, user, password in cursor: + print url, user, password + yield { + 'URL': url, + 'Login': user, + 'Password': password + } + except: + pass + + finally: + cursor.close() + conn.close() + + def run(self, software_name = None): + all_passwords = [] + for path in self.get_paths(): + with tempfile.NamedTemporaryFile() as tmp: + with open(path) as infile: + tmp.write(infile.read()) + + for pw in self.get_logins(tmp.name): + all_passwords.append(pw) + + return all_passwords