如何加速我的蛮力攻击
How To Speed Up My Brute Force Attack
所以我有一个暴力攻击者,我想看看破解我的密码需要多长时间。但是,我去this that estimate your length or places that calculate how long it would take like this one 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 个字符
搜索 space 是 93^6 = 646,990,183,449
如果你可以检查 10^7
pw 一秒钟,你仍然需要
646,990,183,449 / 10^7 / (60 * 60) = 18 hours
破解它。
推论:如果你每秒只能检查一百万 pw,你将需要 180 小时(超过一周)
您正在使用 Python,相对较慢。
不过,您可以更快地将 python 代码更改为 运行。
使用 Numba,这是一个将您的代码编译为汇编的库(我们正在谈论 speed-ups 到 1000X 以上到 100 万)
这是 Numba 的 5 分钟指南
https://numba.readthedocs.io/en/stable/user/5minguide.html
我之前使用过 Numba 来生成素数,根据我个人的经验,更改代码是值得的。大多数情况下,它不需要进行重大更改。
示例:
@jit ##this is most of the times the only change, the jit(just-in-time compiler)
def python_function():
... ...
return xx
注:主要 speed-up 在 CPU-intensive 个项目中提供,如上。
所以我有一个暴力攻击者,我想看看破解我的密码需要多长时间。但是,我去this that estimate your length or places that calculate how long it would take like this one 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 个字符
搜索 space 是 93^6 = 646,990,183,449
如果你可以检查 10^7
pw 一秒钟,你仍然需要
646,990,183,449 / 10^7 / (60 * 60) = 18 hours
破解它。
推论:如果你每秒只能检查一百万 pw,你将需要 180 小时(超过一周)
您正在使用 Python,相对较慢。
不过,您可以更快地将 python 代码更改为 运行。 使用 Numba,这是一个将您的代码编译为汇编的库(我们正在谈论 speed-ups 到 1000X 以上到 100 万)
这是 Numba 的 5 分钟指南 https://numba.readthedocs.io/en/stable/user/5minguide.html
我之前使用过 Numba 来生成素数,根据我个人的经验,更改代码是值得的。大多数情况下,它不需要进行重大更改。 示例:
@jit ##this is most of the times the only change, the jit(just-in-time compiler)
def python_function():
... ...
return xx
注:主要 speed-up 在 CPU-intensive 个项目中提供,如上。