python利用字典破解Zip文件

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

import zipfile

def extractFile(toPath,zFile,password):

    try:

        zFile.extractall(path=toPath,pwd=password);

        print('SCUCESS'+password);

        return password;

    except Exception,e:

        return;

def main():

    zFile = zipfile.ZipFile("/home/james/test.zip");

    passFile = open('/home/james/dict.txt');

    for line in passFile.readlines():
            # 去空格和回车
            password = line.strip('\r\n');

            guess = extractFile("/home/",zFile,password);

            if guess:

                print('SCUCESS'+password);

                exit(0);

 

if __name__=='__MAIN__':

    main();

提示: Linux下给压缩包创建密码命令

zip -r -p 123456 test.zip dict.txt

md5解密网站 : http://www.cmd5.com

转载于:https://my.oschina.net/jamescasta/blog/1491701

你可能感兴趣的:(python利用字典破解Zip文件)