声明:文中所涉及的技术、思路和工具仅供以安全为目的的学习交流使用,任何人不得将其用于非法用途以及盈利等目的,否则后果自行承担!
本文首发于涂寐’s Blogs:http://localhost:4000/article/49fe31ad.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
""" @Project :python黑客 @File :Zip压缩包爆破.py @IDE :PyCharm @Author :涂寐 @Date :2022/2/24 0:01 """
from pyzipper import ZipFile, AESZipFile
def exist(filename): try: with open(filename, 'r') as fp: fp.close() except: print(filename + ' 文件不存在!!!') exit(0)
def read_dicts(filename): with open(filename, 'r') as fp: dicts = [pwd.strip('\n') for pwd in fp.readlines()] fp.close() return dicts return Falsh
def case(zip_file, pwd): try: zip_file.extractall(pwd=str.encode(pwd)) print('滴!您得到一枚密码:' + pwd) return 1 except Exception as e: pass
def blast(zip_file, dicts): for pwd in read_dicts(dicts): if case(zip_file, pwd) == 1: exit(0)
def main(dict_file, zip_file): exist(dict_file) exist(zip_file)
open_zip = ZipFile(zip_file) blast(open_zip, dict_file) open_zip.close()
open_zip = AESZipFile(zip_file) blast(open_zip, dict_file) open_zip.close()
if __name__ == '__main__': dict_file = './makings/1dicts.txt' zip_file = './test_8606.zip'
main(dict_file, zip_file)
|