pimped testpw.py a bit

This commit is contained in:
tabledevil
2019-01-27 23:22:56 +01:00
parent 0c8685e08c
commit 6ff411202a

View File

@@ -2,16 +2,24 @@ import sys
import hashlib
import requests
if len(sys.argv) != 2:
print("Usage: python testpw.py <password>")
exit(1)
url="https://api.pwnedpasswords.com/range/"
hash_object = hashlib.sha1(sys.argv[1].encode("UTF-8"))
pw_hash=hash_object.hexdigest()
first_part=pw_hash[:5]
second_part=pw_hash[5:]
print(pw_hash)
print(first_part)
print(second_part)
furl="{}{}".format(url,first_part)
print(furl)
print("Das gehashte Passwort lautet: {}".format(pw_hash))
print("Es werden lediglich die ersten 5 Zeichen des Hashes übertragen ({})".format(first_part))
print("Dies lässt keinerlei Rückschlusse auf da Passwort zu.")
response=requests.get(furl)
if second_part.lower() in response.text.lower():
print("hash found")
for line in response.text.splitlines():
if second_part.lower() in line.lower():
print("Passwort wurde {} mal im Datenbestand gefunden".format(line.split(":")[1]))
exit(0)
print("Passwort wurde nicht im Datenbestand gefunden")