所以我有一个暴力攻击者,我想看看破解密码需要多长时间。然而,当我去了一些网站,比如this来估计你的长度,或者像这个here那样计算需要多长时间的地方,他们都说一个六位数的密码可以在一秒钟内破解!在
我怎样才能加速我的蛮力程序来匹配这样的速度?在
# Imports
import itertools
import time
# Brute force function
def tryPassword(passwordSet, stringTypeSet):
start = time.time()
chars = stringTypeSet
attempts = 0
for i in range(1, 9):
for letter in itertools.product(chars, repeat=i):
attempts += 1
letter = ''.join(letter)
if letter == passwordSet:
end = time.time()
distance = end - start
return (attempts, distance)
password = "123456"
# Allowed characters
stringType = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~!@#$%^&*()_-+=[{]}|:;'\",<.>/?"
tries, timeAmount = tryPassword(password, stringType)
print("CyanCoding's BFPC cracked the password %s in %s tries and %s seconds!" % (password, tries, timeAmount)))
您的字母集是93个字符。
你的密码是6个字符
搜索空间是
93^6 = 646,990,183,449
如果您可以检查一下
10^7
pw,您仍然需要646,990,183,449 / 10^7 / (60 * 60) = 18 hours
破解它。在
推论:如果你每秒只能检查一百万个密码,你需要180个小时(超过一个星期)
相关问题 更多 >
编程相关推荐