This Ruby script allows you to easily check if any of your LastPass passwords appear in the Pwned Passwords database, indicating they've been compromised in one or more data breaches.
You can read more about the Pwned Passwords database and version two of the API in Troy Hunt's blog post.
Importantly, this script uses the Range API. That means that your actual passwords do not leave your computer. Instead, a short prefix of the SHA1 hash of your password is used to query for potentially matching SHA1 hashes of passwords that have been compromised. The full SHA1 hash of your password is then compared to those results locally to see if there is a match. You can read more about this system, known as k-anonymity, in the blog post.
To use this checker:
- Export your LastPass passwords using the CLI (
lpass export > lastpass.csv
) or the plugin (More Options → Advanced → Export
). - Save the Ruby script and the CSV in the same directory.
- Run the Ruby script using the command
ruby check-passwords -a
.
Any matched passwords will be printed along with its number of occurrences in the Pwned Passwords database.
👍 Thanks @dontmitch for this script.
One thing I had to fix to make it work in my latest environment, replace :
if count = passwords_in_range[suffix.downcase]
with
if count = passwords_in_range[suffix.downcase].to_i
Regards
Olivier