一个简单zip文件破解

利用到了zipfile库,密码为3位字母,可自己设置个3位密码锁的zip,尝试暴力解开。

deff.zip是锁住的压缩包

test.txt是密码生成文档

import zipfile
zFile = zipfile.ZipFile('deff.zip')
f = open('test.txt','a')  
i=['q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m']
for a in i:
	for b in i:
		for c in i:
			passw='%c%c%c'%(a,b,c) 
			f.write('\n'+passw)
f.close()
passFile = open('test.txt')
for line in passFile.readlines():
	password = line.strip('\n')
	try:
		zFile.extractall(pwd = password)
		print 'Password =' + password + '\n'
		exit(0)
	except Exception, e:
		pass

你可能感兴趣的:(python)