编程语言
首页 > 编程语言> > python解压带密码文件

python解压带密码文件

作者:互联网

import zipfile
import rarfile
# from unrar import rarfile
if __name__ == '__main__':
file = zipfile.ZipFile("flag.zip")
# file = rarfile.RarFile("pwd.rar")
with open('top10000.txt', 'r', encoding='utf8') as f:
passwords = f.readlines()
for passwd in passwords:
passwd = passwd.strip('\n')
try:
file.extractall(pwd=passwd.encode('utf-8'))
# file.extractall(pwd=password)#rar解压缩
print(f"压缩包的密码是:{passwd}")
break
except:
print('密码错误!')

标签:__,解压,python,密码文件,pwd,passwd,file,import,rar
来源: https://www.cnblogs.com/xzztj/p/15784986.html