zip文件口令破解器

使用了zipfile包,argparse包,threading包
实现获取用户输入参数,以及多线程处理的功能。
同样使用字典破解法。

#coding=utf-8
#一个zip文件口令破解器-多线程版本

import zipfile
import argparse
from threading import Thread
def extractFile(zFile,password):
    try:
        zFile.extractall(pwd=password)
        print "found password "+password+"\n"
    except:
        pass
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("target",help="target zip file",type=str)
    parser.add_argument("dictionary",help="dictionary of code",type=str)
    args = parser.parse_args()
    target = args.target
    dictionary = args.dictionary
    # if (target == None) | (dictionary == None):
    #     print "input the right parameters"
    #     exit(0)
    zFile = zipfile.ZipFile(target)
    passFile = open(dictionary)
    for line in passFile.readlines():
        password = line.strip("\n")
        t = Thread(target=extractFile,args=(zFile,password))
        t.start()

if __name__=="__main__":
    main()```

你可能感兴趣的:(zip文件口令破解器)