27 agosto 2012

Linux: How to export Google Chrome passwords to CSV file

Original Post: Linux: How to export Google Chrome passwords to CSV file 

Having spent some time googling for a way to export Chrome passwords to an external file to my surprise I could not find a straightforward solution that would work irregardless of the version of Chrome/Chromium. Finally I have found this page which provided the key to the solution.
Older versions of Chrome/Chromium for Linux stored unencrypted passwords in an SQLite database under:
### Google Chrome:
    ~/.config/google-chrome/Default/Login Data

    ### Chromium:
    ~/.config/chromium/Default/Login Data
In newer versions of Chrome this file is still present, but the passwords are not there anymore - they are stored using the encrypted password storage provided by the system, either Gnome Keyring or KWallet, which means that simply dumping the tables will not work.
The method below relies on forcing Chrome to use a temporary profile folder in combination with unencrypted password storage. This approach will not affect your current Chrome profile in any way.
So, to export your passwords to a human readable text file:
  1. Connect to your Google Account in Chrome Settings so that your passwords are synched with the Google cloud storage. Make sure that you have ticked Passwords in Advanced Sync Settings.
  2. Wait for a while until the data is synched, and then close all the Chrome windows.
  3. Start Chrome using one of the two command lines below. The easiest way to figure out whether you are using Google Chrome or Chromium is to look at the icon — Google Chrome has a green-red-yellow icon , while the Chromium icon is in shades of blue . As an alternative, click the spanner icon in the top right corner and select About Chrome/Chromium.
    ### Google Chrome
        google-chrome --user-data-dir=/tmp/chrome-tmp --password-store=basic
    
    ### Chromium
        chromium --user-data-dir=/tmp/chrome-tmp --password-store=basic
    
    This will launch Chrome with a custom profile folder without affecting your current profile.
  4. Setup Google Synching for the new temporary profile and make sure that all the passwords are restored from the Google cloud storage by verifying they are there under Settings → Personal Stuff → Manage Saved Passwords. If they do not appear there, then wait a couple of minutes until they are pulled from the cloud.
  5. Exit Chrome.
  6. Next, open a terminal and change to the newly created Chrome profile
    cd /tmp/chrome-tmp/Default
    
  7. Now, open the Login Data SQLite database using the sqlite3 command line utility and dump the logins table. For this to work, you need to have sqlite3 installed on your system.
    sqlite3 'Login Data'
    
  8. Next, at the SQLite prompt enter the commands below. For help on available commands type .help at the prompt.

    .mode csv               # other options are `html', `tabs', etc.
    .headers on
    .separator ","
    .output chrome_passwords.csv
    select * from logins;
    .exit
    
Now you should have a file named chrome_passwords.csv containing all your Chrome passwords. To open it with LibreOffice, type:
libreoffice --calc chrome_passwords.csv

Nessun commento:

Posta un commento