Skip to content

Instantly share code, notes, and snippets.

@codekoala
Last active June 24, 2023 11:54
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save codekoala/204f68946134d1573eb8960b7ef6c951 to your computer and use it in GitHub Desktop.
Save codekoala/204f68946134d1573eb8960b7ef6c951 to your computer and use it in GitHub Desktop.
Dump all passwords saved in Google Chrome (tested with Chrome 56.0.2906.0 on Arch Linux)
// Modified version of https://github.com/megmage/chrome-export-passwords
//
// This script allows you to dump all of the passwords stored in your Chrome
// profile. I tested it with Chrome 56.0.2906.0 dev (64-bit) on Arch Linux and
// it worked quite well.
//
// Usage:
//
// - Navigate to chrome://settings-frame/passwords
// - Copy this code into a snippet in Chrome
// - Hit F12 or Ctrl+Shift+I to open the developer tools
// - Switch to the "Sources" tab
// - Switch to the "Snippets" tab in the left pane of the "Sources" tab
// - Click the "+" button in the top of the left pane to add a new
// snippet, giving it a name (dump_passwords.js)
// - Paste this code into the snippet and hit Ctrl+S to save it
// - Right click the newly-created snippet in the left pane and select
// "Run"
// - You should see the password list start to unmask your passwords one by
// one while scrolling through the list. Once all passwords have been
// revealed, the page contents will be replaced with CSV containing all
// of your passwords.
// Number of milliseconds to wait between each password being unmasked. If you
// see errors in your console while running this snippet or your password list
// appears to be incomplete consider increasing this value a little and
// running again.
var DELAY = 10;
var out = "" // will hold the raw password list
, out2 = "" // will hold the CSV password list
, pm = PasswordManager.getInstance()
, pl = pm.savedPasswordsList_
, model = pl.dataModel;
/**
* For each entry in the list, request that the password be unmasked.
*
* When all passwords have been revealed, dump all passwords to the console
* and to CSV.
**/
function unmask_password(idx) {
// for me it was necessary to actually scroll to each entry before the
// password could be revealed
var item = pl.getListItemByIndex(idx);
if (item !== null) { item.scrollIntoView({behavior: 'instant'}); }
// reveal the password
PasswordManager.requestShowPassword(idx);
// queue up the next password to be revealed
if (idx < model.length) {
setTimeout(function (i) {
return function () { unmask_password(i); }
}(idx + 1), DELAY);
} else {
// or dump the password list if everything is already unmasked
dump_unmasked_passwords();
}
}
function dump_unmasked_passwords() {
out2 += '# Generated by Password Exporter; Export format 1.1; Encrypted: false\n';
out2 += '"hostname","username","password","formSubmitURL","httpRealm","usernameField","passwordField"';
for (i = 0; i < model.length; i++) {
var arr = model.array_[i]
, url = arr.url
, loc = document.createElement('a')
, username = arr.username
, item = pl.getListItemByIndex(i)
, pw = item.childNodes[0].childNodes[2].childNodes[0].value;
loc.href = url
out += "\n" + loc.hostname + " " + username + " " + pw;
out2 += '\n"' + loc.hostname + '","' + username + '","' +
pw.replace(/"/g, '""') + '","' + url + '"," "," "," "';
}
console.log(out);
document.body.innerHTML = '<pre>' + out2 + '</pre>';
}
function dump_passwords() {
unmask_password(0);
}
dump_passwords();
@kenorb
Copy link

kenorb commented Feb 1, 2018

@dinocaputo
Copy link

Getting the following error when I do this:
Uncaught ReferenceError: PasswordManager is not defined
at :33:10
(anonymous) @ VM128:33

Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment