Last active
August 29, 2015 14:26
-
-
Save grenade/b3affc001adb90163835 to your computer and use it in GitHub Desktop.
This loopy bit of python will change multiple Gnome Keyring (Chrome on Linux) passwords in one go.
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
| #! /usr/bin/env python | |
| # use this script at your own risk. it works for me, but if it eats your homework and kills your dog, it's on you. | |
| import secretstorage | |
| # important: always run this script at least once with `mock_run_only = True` first to understand what would be changed. | |
| mock_run_only = True | |
| # leave empty if you only want to replace all old_passwords with new_password regardless of username | |
| search_username = '' | |
| # leave empty if you've set search_username and want to replace with new_password regardless of old_password | |
| old_password = 'my_old_password' | |
| # set to your new password | |
| new_password = 'my_new_password' | |
| def mass_password_reset(): | |
| username_must_match = (search_username != '') | |
| password_must_match = (old_password != '') | |
| bus = secretstorage.dbus_init() | |
| collections = secretstorage.get_all_collections(bus) | |
| for collection in collections: | |
| collection_label = '%s' % collection.get_label() | |
| items = collection.get_all_items() | |
| for item in items: | |
| label = '%s' % item.get_label() | |
| username = '' | |
| attributes = item.get_attributes() | |
| if attributes and 'username_value' in attributes: | |
| username = '%s' % attributes['username_value'] | |
| password = '%s' % item.get_secret() | |
| if (new_password != password): | |
| if (not password_must_match or (password_must_match and old_password == password)): | |
| if (not username_must_match or (username_must_match and username != '' and search_username == username)): | |
| print('found: %s, username: %s, password: %s' % (label, username, password)) | |
| if (not mock_run_only): | |
| item.set_secret(new_password) | |
| if __name__ == '__main__': | |
| mass_password_reset() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment