Last active
April 26, 2021 20:56
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[+] 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.