Python必备技能之ZIP密码爆破
-
了解ZipFile压缩文件爆破脚本写法
-
准备密码本
直接发之前做图片隐写拿到的一个压缩包和得到的密码本链接:https://pan.baidu.com/s/1Dpd0mWP9wxfvS57YgTFhvQ
提取码:olix
(1)将压缩包和密码本导入我们的pycharm里面
(2)构造playload1 # -*- coding:utf -8 -*- 2 """ 3 @Author:Forchan 4 @File:blast.py 5 @Time:2021/02/5 6 """ 7 import zipfile 8 import traceback 9 10 def read_dicts(filename): 11 dicts = [] 12 with open(filename, 'r') as fp: 13 dicts = [pwd.strip() for pwd in fp.readlines()] 14 return dicts 15 16 17 18 def blast(zip_f, pwd): 19 try: 20 zip_f.extractall('./temp',pwd=pwd.encode()) 21 return pwd 22 except Exception as e: 23 if 'Bad password' in str(e): 24 return False 25 traceback.print_exc() 26 27 28 if __name__ == '__main__': 29 dict_file = './zip_dict.txt' 30 31 32 zip_file = zipfile.ZipFile('./test.zip') 33 for password in read_dicts(dict_file): 34 result = blast(zip_file,password) 35 if result: 36 print(f'[+] get password:{result}') 37 break 38 else: 39 print('[-] not found password.')
提醒萌新:代码的大致意义是忽略False的警告,直接查看pwd
成功拿到flag
未亡人

浙公网安备 33010602011771号