Skip to content

Instantly share code, notes, and snippets.

@7h3rAm
Last active April 26, 2021 20:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7h3rAm/22d20e4ef2cffb89dfdeabef7a4004d7 to your computer and use it in GitHub Desktop.
Save 7h3rAm/22d20e4ef2cffb89dfdeabef7a4004d7 to your computer and use it in GitHub Desktop.
This JS code snippet helps to extract passwords from Chrome. It's based on http://superuser.com/questions/655294/how-can-i-export-chrome-passwords/675167#675167 answer.
var out = [];
var pm = PasswordManager.getInstance();
var model = pm.savedPasswordsList_.dataModel;
console.log(model);
var pl = pm.savedPasswordsList_;
for (var i = 0; i < model.length; i++) {
PasswordManager.requestShowPassword(i);
}
alert('After you press Ok results should appear in ~5 seconds.\n' +
"If password fields are empty, try increasing the timeout in the last line," +
" i.e. set to 10000 for 10 seconds");
setTimeout(
function () {
out.push('domain,url,username,password');
for (var i = 0; i < model.length; i++) {
var record = model.array_[i];
var user = record.username;
var item = pl.getListItemByIndex(i);
var proto = record.url.split('://')[0];
/* handle exception while referencing a member called "value" for each password entry */
if (item.querySelector('div.password input') != null) {
pass = item.querySelector('div.password input').value;
} else {
pass = null;
}
var proto = record.url.split('://')[0];
var line = `${record.shownOrigin},${record.url},${user},${pass}`;
out.push(line);
console.log(line);
}
document.body.innerText = out.join('\n');
}, 5000);
@7h3rAm
Copy link
Author

7h3rAm commented Oct 21, 2016

[+] Included an if-else for exception handling of password entries
[+] Exported minimal fields: domain, url, username and password

The output can be saved to a csv and imported into KeepassX.

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