如何扩展我现有的功能,以便让它在锁定的zip文件上尝试密码
chars = "abcdefghijklmnopqrstuvwxyz"
password = "hello"
def brute_force(x, y):
#Where x stands for chars(list to check in) and y stands for password variable to check against
for length in range(1, 100):
to_attempt = product(x, repeat=length)
for attempt in to_attempt:
i = i + 1
if ''.join(attempt) == y:
print('Password: ' + ''.join(attempt))
return
答案 0 :(得分:0)
def brute_force(x, y):
#since you already have the password just return it
return y
好的,这可能不是你要找的答案......
但实际上我知道的唯一方法(假设你不知道解密可能的任何加密的漏洞)就是强行它......
粗略的许多系统都有可以利用的vunerabilities来获取访问权限而无需“猜测”密码如果您问如何不包含y而是针对真实文件进行测试,请尝试zipfile module,其中包含大多数方法的密码选项
答案 1 :(得分:0)
使用zipfile
模块
import zipfile
z = zipfile.Zipfile('your_zip_file')
def searching(z,x):
try:
z.extractall(pwd=x)
print "\n[+]Password found: " + x
exit
except:
pass
# loop over you combination call searching
searching(z,pwd)
这可能会对你有所帮助。你可以使用线程的概念来加快速度
答案 2 :(得分:0)
我不会完全为您重新编写您的功能,但要测试您将执行的每个attempt
(import zipfile
位于顶部):
f = zipfile.ZipFile('path/to/file')
for attempt in attempts:
try:
f.extractall(pwd=attempt)
except RuntimeError:
continue
else:
return attempt