HackTools————4、zip口令破解

xiaoxiao2021-02-28  7

已知密码解压缩

思路:

使用python中的zipfile库中的解压缩来实现对压缩包的解压

代码:

#encoding:utf-8 import zipfile #导入zipfile zFile=zipfile.ZipFile('eval.zip') #用带有口令保护的zip名来实例化ZipFile类 try: zFile.extractall(pwd='1235') #使用zipfile的内置方法extractall来解压(密码已知的条件下+ except Exception,e: print e exit(0)

运行结果:

使用字典进行zip密码暴力破解

思路:

通过对一个密码字典的遍历来实现对一个zip密码的暴力破解

代码:

#encoding:utf-8 import zipfile def extractfile(zFile,password): try: zFile.extractall(pwd=password) return password except Exception,e: print e def main(): zFile=zipfile.ZipFile('eval.zip') passFile=open('dictionary.txt') for line in passFile.readlines(): password=line.strip('\n') guess=extractfile(zFile,password) if guess: print "Password is:"+password exit(0) if __name__ == '__main__': main()

多线程实现

#encoding:utf-8 import zipfile from threading import Thread def extractfile(zFile,password): try: zFile.extractall(pwd=password) print "Found password is "+password except: pass def main(): Zipfile=zipfile.ZipFile('eval.zip') passfile=open('dictionary.txt') for line in passfile.readlines(): password=line.strip('\n') t=Thread(target=extractfile,args=(Zipfile,password)) t.start() if __name__ == '__main__': main()
转载请注明原文地址: https://www.6miu.com/read-2400102.html

最新回复(0)