python多线程爆破压缩包密码

import zipfile
from threading import Thread   #多线程库
import optparse   #选定字典或者文件
def extractFile(zfile,password):
    try:
        zfile.extractall(pwd=password)
        print('[+] found password' + password +'\n')
    except:
        pass
def main():
    #zfile=zipfile.ZipFile('decode.zip')
    #passfile=open('dictionmary.txt')
    parser=optparse.OptionParser("usage%prog "+\
    "-f -d ")
    parser.add_option('-f',dest='zname',type='string',\
    help='specify zip file')
    parser.add_option('-d',dest='dname',type='string',\
    help='specify sictionary file')
     (options,args)=parser.parse_args()
    if (options.zname==None) | (options.dname==None):
        print(parser.usage)
    else:
        zname=options.zname
        dname=options.dname
    zfile=zipfile.(zname)
    passfile=open(dname)
    for line in passfile.readlines():
        password=line.strp('\n')
        t=Thread(target=extractFile,args=(zfile,password))
        t.start()
        #guess=extractFile(zfile, password)
        #if guess:
        #    print('[+] Password='+password+'\n')
        #    exit(0)
if __name__=='__main__':
    main()

转载于:https://www.cnblogs.com/kk328/p/11167715.html

你可能感兴趣的:(python)