-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword_auditor.py
More file actions
49 lines (40 loc) · 1.26 KB
/
Copy pathpassword_auditor.py
File metadata and controls
49 lines (40 loc) · 1.26 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import re
def audit_password(password):
"""
Audits a password against standard complexity rules.
Returns a score and a list of missing requirements.
"""
score = 0
feedback = []
# Rule 1: Length
if len(password) >= 8:
score += 1
else:
feedback.append("Password is too short (min 8 chars).")
# Rule 2: Upper and Lowercase
if re.search(r"[a-z]", password) and re.search(r"[A-Z]", password):
score += 1
else:
feedback.append("Missing mix of uppercase and lowercase letters.")
# Rule 3: Numbers
if re.search(r"\d", password):
score += 1
else:
feedback.append("Missing a number.")
# Rule 4: Special Characters
if re.search(r"[ !#$%&'()*+,-./:;<=>?@[\]^_`{|}~]", password):
score += 1
else:
feedback.append("Missing a special character.")
return score, feedback
if __name__ == "__main__":
print("--- Password Policy Auditor ---")
user_pass = input("Enter password to test: ")
score, issues = audit_password(user_pass)
print(f"\nPassword Score: {score}/4")
if score == 4:
print("[+] Status: STRONG")
else:
print("[-] Status: WEAK")
for issue in issues:
print(f" - {issue}")