-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpassword.py
34 lines (30 loc) · 942 Bytes
/
password.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import sys
import requests
import hashlib
import time
passwords = sys.argv[1:]
if not passwords:
raise ("Please supply at least one password")
for password in passwords:
sha1 = hashlib.sha1(password.encode()).hexdigest()
to_send = sha1[:5]
url = f"https://api.pwnedpasswords.com/range/{to_send}"
possibilities = requests.get(url).text.split("\r\n")
for possibility in possibilities:
if sha1[5:].upper() in possibility:
print(
"For password",
password,
"there are",
possibility.split(":")[1],
"leaks",
flush=True,
)
break
else:
print(f"Your password, {password}, is safe! Nothing found", flush=True)
sleep_time = 3
for i in range(sleep_time, 0, -1):
print("\tSleeping for", i, "seconds...\r", flush=True, end="")
time.sleep(1)
print()