Last active
March 22, 2019 15:06
-
-
Save AWRyder/57987e862f83130eef98f3b299334186 to your computer and use it in GitHub Desktop.
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
import sys | |
import hashlib | |
import requests | |
hash_object = hashlib.sha1(sys.argv[1].encode('utf-8')) | |
hex_dig = hash_object.hexdigest() | |
print('Hex: '+hex_dig) | |
print('First 5 chars: '+hex_dig[:5]) | |
response = requests.get('https://api.pwnedpasswords.com/range/'+hex_dig[:5]) | |
response_text = response.text | |
if response.status_code != 200: | |
print(response_text) | |
exit(0) | |
response_text_lines = response_text.splitlines(False) | |
for line in response_text_lines: | |
word = line.split(':')[0] | |
quantity = line.split(':')[1] | |
if (hex_dig[:5]+word).upper() == hex_dig.upper(): | |
print("Password insecure. Found "+quantity+" times on leaks.") | |
exit(0) | |
print("Password is safe. Nothing was found.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment