我编写了一个Python脚本来检查密码,但是这个脚本无法检测单词"star"
我的脚本如下:
import os
import sys
import time
while True:
user_password = input("Enter your password: ")
# Processing String.
try:
user_password = int(str(user_password))
inta = True
except Exception:
user_password = str(user_password).lower()
inta = False
passlen = len(str(user_password))
if inta == True:
print("PIN not supported.")
elif passlen != 3:
print(f"Password less than or greater than 4 characters not supported.")
else: break
dic = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j','k',
'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't','u','v',
'w', 'x', 'y', 'z']
os.system('cls')
os.system('color 02')
if not inta:
guess = ""
a, b, c, d= 0,0,0,0
st = time.time()
while (True):
guess = ""
g1 = dic[a]
g2 = dic[b]
g3 = dic[c]
g4 = dic[d]
guess = f'{g1}{g2}{g3}{g4}'
# print(guess)
sys.stdout.write(f'\rPassword Guessing: {guess}, Time: {time.time()-st:.2f}s')
sys.stdout.flush()
if (guess!=user_password):
if d==25:
if c==25:
if b==25:
a+=1
b,c,d=0,0,0
else:
b+=1
c=0
else:
c+=1
d=0
else:
d+=1
elif guess == 'star':
print('star')
else:
et = time.time() - st
break
sys.stdout.write(f"\rYour password is {guess}, Time Taken: {et:.2f}s")
time.sleep(2)
os.system('color 07')
在多次运行之后,会检测到许多其他单词,如"aaaa"
、"rrrr"
、"tttt"
。但是这个脚本无法检测单词"star"
不是最好的,但它做你想要的
相关问题 更多 >
编程相关推荐