如何加速我的蛮力A

2024-06-16 08:57:50 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我有一个暴力攻击者,我想看看破解密码需要多长时间。然而,当我去了一些网站,比如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)))

Tags: inimport密码timepasswordstartitertools多长时间
1条回答
网友
1楼 · 发布于 2024-06-16 08:57:50

您的字母集是93个字符。
你的密码是6个字符

搜索空间是93^6 = 646,990,183,449

如果您可以检查一下10^7pw,您仍然需要

646,990,183,449 / 10^7 / (60 * 60) = 18 hours

破解它。在

推论:如果你每秒只能检查一百万个密码,你需要180个小时(超过一个星期)

相关问题 更多 >