Skip to content

Instantly share code, notes, and snippets.

@cmatskas
Created October 28, 2015 17:12
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save cmatskas/6e3fa687e97651416430 to your computer and use it in GitHub Desktop.
Save cmatskas/6e3fa687e97651416430 to your computer and use it in GitHub Desktop.
ExportChromePasswords.js
var decryptedRow="";
var pm = PasswordManager.getInstance();
var model = pm.savedPasswordsList_.dataModel;
var pl = pm.savedPasswordsList_;
for(i=0;i<model.length;i++){
PasswordManager.requestShowPassword(i);
};
setTimeout(function(){
decryptedRow += '"hostname","username","password","formSubmitURL","httpRealm","usernameField","passwordField"';
for(i=0; i<model.length; i++){
var item = pl.getListItemByIndex(i);
decryptedRow += '<br/>"http://'+model.array_[i][0]+'","'+model.array_[i][1]+'","'+item.childNodes[0].childNodes[2].childNodes[0].value+'","http://'+model.array_[i][0]+'"," "," "," "';
};
document.write(decryptedRow);
}
,300);
@hantuzun
Copy link

hantuzun commented Jun 5, 2016

updated

var pm = PasswordManager.getInstance();
var pl = pm.savedPasswordsList_;
var model = pm.savedPasswordsList_.dataModel;

setTimeout(function(){
  var item, url, user, pass
  var decryptedRow = '"url","username","password"\n';
  for (i=0; i < model.length; i++) {
    PasswordManager.requestShowPassword(i);
    item = pl.getListItemByIndex(i).childNodes[0];
    url = item.childNodes[0].childNodes[0]
    user = item.childNodes[1].childNodes[0].value
    pass = item.childNodes[2].childNodes[0].value
    decryptedRow += url + ', ' + user + ', ' + pass + '\n'
  };
  console.log(decryptedRow);
}
,300);

@airs0urce
Copy link

airs0urce commented Jan 17, 2017

Updated for Chrome 55 on MacOS 10.12.2. Tested on 403 passwords.
During processing you can see percent of processed passwords.
Small note: if you have many passwords, Chrome will ask password several times during export.

var pm = PasswordManager.getInstance();
var pl = pm.savedPasswordsList_;

function sleep(ms) {
  return new Promise((r) => { setTimeout(() => {r()}, ms) })
}


var model = pm.savedPasswordsList_.dataModel;
(async function() {
  await sleep(1000);
  var item, url, user, pass;
  
  pl.scrollTop = 0;
  var decryptedRow = '"url","username","password"\n';

  for (i=0; i < model.array_.length; i++) {
    var percent = ((i+1) / model.array_.length * 100).toFixed(2);
    console.log('Processing: ' + percent + '%');

    pass = null;
    await sleep(100);
    PasswordManager.requestShowPassword(i);
    await sleep(600);
    
    while (! pass || pass.trim().length == 0) { // while pass length == 0, Chrome showing password dialog
      try {
        item = pl.getListItemByIndex(i).childNodes[0];
      } catch (e) {
        await sleep(1000);
        try {
          item = pl.getListItemByIndex(i).childNodes[0];
        } catch (e2) {
          console.log('ERROR on index ' + i, pl.getListItemByIndex(i));
        }
      }
      url = item.childNodes[0].childNodes[0]
      user = item.childNodes[1].childNodes[0].value
      pass = item.childNodes[2].childNodes[0].value
      if (pass.trim().length == 0) {
        await sleep(1000);
      }
    }
    
    decryptedRow += url + ', ' + user + ', ' + pass + '\n'

    pl.scrollTop += 32;
  };

  console.log(decryptedRow);

})();

@zzh8829
Copy link

zzh8829 commented Mar 6, 2017

If you want to speed up the above script, just replace all sleep timer to 10. Tested on 840 rows of passwords, reducing waiting time does not change anything and speed up the process by almost 100x

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