用Python怎样破解zip加密文件,操作是什么
Admin 2022-08-26 群英技术资讯 948 次浏览
今天这篇给大家分享的知识是“用Python怎样破解zip加密文件,操作是什么”,小编觉得挺不错的,对大家学习或是工作可能会有所帮助,对此分享发大家做个参考,希望这篇“用Python怎样破解zip加密文件,操作是什么”文章能帮助大家解决问题。解压时可以提供密码zfile.extractall("./", pwd=password.encode("utf8"))
通过函数itertools.permutations("abc", 3)实现全字符的全排列:abc/acb/bca/bac/cab/cba
本文介绍的zip文件知道密码一共是4位的,密码字符的范围是a-z1-0。并且不存在重复字符的,不会有“aabb”的密码。zip压缩时是选择了zip传统加密!
导入zipfile模块,使用其中的extractall()函数。
import itertools
filename = "readme.zip"
# 创建一个解压的函数,入参为文件名和密码
# 并使用try-except,避免报错中断程序。
def uncompress(file_name, pass_word):
try:
with zipfile.ZipFile(file_name) as z_file:
z_file.extractall("./", pwd=pass_word.encode("utf-8"))
return True
except:
return False
import zipfile
import itertools
filename = "readme.zip"
# 创建一个解压的函数,入参为文件名和密码
# 并使用try-except,避免报错中断程序。
def uncompress(file_name, pass_word):
try:
with zipfile.ZipFile(file_name) as z_file:
z_file.extractall("./", pwd=pass_word.encode("utf-8"))
return True
except:
return False
# chars是密码可能的字符集
chars = "abcdefghijklmnopqrstuvwxyz0123456789"
for c in itertools.permutations(chars, 4):
password = ''.join(c)
print(password)
result = uncompress(filename, password)
if not result:
print('解压失败。', password)
else:
print('解压成功。', password)
break
文件压缩时,一些注意的事项:

查过一些资料,zip压缩文件密码最长为12位,在原来的程序上增加上一个for循环就可以实现破解密码了。
import zipfile
import itertools
filename = "readme.zip"
def uncompress(file_name, pass_word):
try:
with zipfile.ZipFile(file_name) as z_file:
z_file.extractall("./", pwd=pass_word.encode("utf-8"))
return True
except:
return False
chars = "abcdefghijklmnopqrstuvwxyz0123456789"
for i in range(12):
for c in itertools.permutations(chars, i):
password = ''.join(c)
print(password)
result = uncompress(filename, password)
if not result:
print('解压失败。', password)
else:
print('解压成功。', password)
break
此方法可以是实现破解zip文件的密码,python可以完成一些好玩的事情。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
这篇文章主要介绍了聊聊机器学习的标准化、归一化、正则化、离散化和白化,帮助大家更好的理解和学习使用python进行机器学习,感兴趣的朋友可以了解下
1、首先用pip来安装pymysqlpipinstallmysql报错:cryptographyrequiressetuptools18 5ornewer,pleaseupgradetoanewversion2、我想到的是更
这篇文章主要和大家分享几个Python Pandas中处理CSV文件的常用技巧,如:统计列值出现的次数、筛选特定列值、遍历数据行等,需要的可以参考一下
这篇文章介绍了Python使用RSA库加密和解密的方法,文中通过示例代码介绍的非常详细。对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
python中的str:1、Python中包含字符串,字符串的类型为str。str函数是Python的内置函数,它将参数转换成字符串类型,即人适合阅读的形式;2、主要使用有无参调用和不省略参数。
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008