【发布时间】:2023-09-05 19:19:01
【问题描述】:
我正在尝试打开一个受保护的 zip 文件,我知道前 5 个字符是 Super 并且密码长度为 8 个字符,没有数字或符号我在 python 中使用此代码来帮助我,但事实并非如此工作有人可以帮忙吗?
代码:
import zipfile
import itertools
import time
# Function for extracting zip files to test if the password works!
def extractFile(zip_file, password):
try:
zip_file.extractall(pwd=password)
return True
except KeyboardInterrupt:
exit(0)
except Exception as e:
pass
# The file name of the zip file.
zipfilename = 'planz.zip'
# The first part of the password.
first_half_password = 'Super'
# We don't know what characters they add afterwards...
alphabet = 'abcdefghijklmnopqrstuvwxyz'
zip_file = zipfile.ZipFile(zipfilename)
# For every possible combination of 3 letters from alphabet...
for c in itertools.product(alphabet, repeat=3):
# Add the three letters to the first half of the password.
password = first_half_password+''.join(c)
# Try to extract the file.
print("Trying: %s" % password)
# If the file was extracted, you found the right password.
if extractFile(zip_file, password):
print('*' * 20)
print('Password found: %s' % password)
print('Files extracted...')
exit(0)
# If no password was found by the end, let us know!
print('Password not found.')
【问题讨论】:
-
不工作意味着您收到错误,如果是,请提供错误?
-
它正在工作,但它正在打印 Password not found
-
你没有检查大写字母
-
我该怎么做?
标签: python brute-force password-recovery