forked from Datalux/instagram-weak-encryption
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstasecpass.py
45 lines (38 loc) · 1.35 KB
/
instasecpass.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
35
36
37
38
39
40
41
42
43
44
45
import getpass
import re
def is_strong_password(password):
# Check if password meets strength criteria (at least 8 characters, includes letters and numbers)
if len(password) >= 8 and re.search(r"[A-Za-z]", password) and re.search(r"\d", password):
return True
return False
attempts = 0
max_attempts = 5
invalid_attempts = []
while attempts < max_attempts:
enc = getpass.getpass('Insert encrypted password: ')
attempts += 1
if len(enc) < 3:
print("Error: Password too short. Please provide a valid encrypted password.")
invalid_attempts.append(enc)
continue
c = enc.split(':')[3] if ':' in enc else enc
cl = len(c)
pad = (int)((cl / 4) - 36)
pad1 = 1 if c[-1] == '=' else 0
pad2 = 1 if c[-2] == '=' else 0
pl = (len(c) - 136 - pad - pad1 - pad2)
if pl < 0:
print("Error: Invalid encrypted password format.")
invalid_attempts.append(enc)
else:
print("Password length: " + str(pl))
if is_strong_password(c):
print("Password strength: Strong")
else:
print("Password strength: Weak")
break
else:
print("Error: Too many invalid attempts. Please try again later.")
# Log invalid attempts
if invalid_attempts:
print("Invalid attempts were logged for review.")