Created
January 19, 2019 22:52
-
-
Save missett/daf30cbf077dfeab695d62e98b6b9cc1 to your computer and use it in GitHub Desktop.
Checks a list of passwords against Have I Been Pwned to find which passwords you should change
This file contains 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 | |
import hashlib | |
import httplib | |
with open("passwords.txt", "r") as file: | |
for password in file: | |
password = password.strip() | |
sha = hashlib.sha1(password).hexdigest().upper() | |
head = sha[:5] | |
tail = sha[5:] | |
uri = "/range/%s" % head | |
connection = httplib.HTTPSConnection("api.pwnedpasswords.com") | |
connection.request("GET", uri) | |
response = connection.getresponse().read() | |
for entry in response.splitlines(): | |
fullhash, count = entry.split(":") | |
# print(fullhash) | |
if fullhash == tail: | |
print "%s found %s times" % (password, count) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment