从零开始学习python-暴力破译zip文件 7月11日

Python

                                                                                                                     ---小白121的记录笔记


暴力破译ZIP压缩包文件

需要调用的库

  • itertools
  • zipfile
  • time                                                                                
import zipfile
import time
from itertools import product

path = input('please input decipher the ZIP File: ')

def pwd(x=6):
    iter = ['1234567890']
    for i in iter:
        for repeat in range(1, x+1):
            for ps in product(i, repeat = repeat):
                yield''.join(ps)

def run(path, passwd):
    if path[-4:] == '.zip':
        zip = zipfile.ZipFile(path, 'r', zipfile.zlib.DEFLATED)
        try:
            zip.extractall(path='C:\\Users\\121812\\Desktop\\', members=zip.namelist(), pwd=passwd.encode('utf-8'))
            print("\n\tsuccess! passwd is %s\t\n"%passwd)
            zip.close()
            return True
        except:
            print('--- error! passwd : %s ---' %passwd)
            return False


if __name__ == '__main__':
    start = time.clock()
    print("--- decipher now ! ---")
    for temp in pwd(8):
        if run(path, temp):
            break
    print('End speed time is %s' %(time.clock() - start))

    

                                                                                                                改编自---童年的夏天

单词:

decipher    破译

member    成员

compress    压缩

yield    屈服

got    得到

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值