import zipfile z = zipfile.ZipFile(filename, 'r') for i in z.infolist(): print i.file_size, i.header_offset
import zipfile #导入模块,它是做压缩和解压缩的 password="123" #我们设定的口令 zfile = zipfile.ZipFile("test.zip") #要解压缩的压缩包 zfile.extractall(path='C:\\Users\\Administrator\\Desktop\\', members=zfile.namelist(), pwd=password.encode('utf-8')) #进行解压缩操作,path为输出的路径
import zipfile zfile = zipfile.ZipFile("test.zip") passFile=open('pwd.txt') #读取你设定的密码文件 for line in passFile.readlines(): try: password = line.strip('\n') zfile.extractall(path='C:\\Users\\Administrator\\Desktop\\', members=zfile.namelist(), pwd=password.encode('utf-8')) break except: print("又错了")
1223 abc aaa 123
好了,这就完成了zip文件口令的暴力破解,其实只是很巧妙的利用了try except异常机制,当解压正常的时候就正常密码正常,解压失败会报出异常,动手试试
相关推荐:
Python压缩解压缩zip文件及破解zip文件密码的方法
Python压缩与解压缩ZIP文件的实现方法
python中zip函数的使用方法
以上就是实例详解利用Python暴力破解zip文件口令的方法的详细内容,更多请关注Gxl网其它相关文章!
查看更多关于实例详解利用Python暴力破解zip文件口令的方法的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did81675