pimped testpw.py a bit
This commit is contained in:
18
testpw.py
18
testpw.py
@@ -2,16 +2,24 @@ import sys
|
|||||||
import hashlib
|
import hashlib
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print("Usage: python testpw.py <password>")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
url="https://api.pwnedpasswords.com/range/"
|
url="https://api.pwnedpasswords.com/range/"
|
||||||
hash_object = hashlib.sha1(sys.argv[1].encode("UTF-8"))
|
hash_object = hashlib.sha1(sys.argv[1].encode("UTF-8"))
|
||||||
pw_hash=hash_object.hexdigest()
|
pw_hash=hash_object.hexdigest()
|
||||||
first_part=pw_hash[:5]
|
first_part=pw_hash[:5]
|
||||||
second_part=pw_hash[5:]
|
second_part=pw_hash[5:]
|
||||||
print(pw_hash)
|
print(pw_hash)
|
||||||
print(first_part)
|
|
||||||
print(second_part)
|
|
||||||
furl="{}{}".format(url,first_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)
|
response=requests.get(furl)
|
||||||
if second_part.lower() in response.text.lower():
|
for line in response.text.splitlines():
|
||||||
print("hash found")
|
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")
|
||||||
|
|||||||
Reference in New Issue
Block a user