├── README.md ├── password.txt └── zipcrack.py /README.md: -------------------------------------------------------------------------------- 1 | # 破解zip压缩包密码 2 | ``` 3 | git clone https://github.com/luckman666/zipCrack.git 4 | cd zipCrack 5 | python zipcrack.py -f file.zip -d password.txt 6 | ``` 7 | -------------------------------------------------------------------------------- /zipcrack.py: -------------------------------------------------------------------------------- 1 | # -*- encoding = 'utf-8' -*- 2 | import zipfile 3 | import optparse 4 | 5 | 6 | def extractFile(zFile,password): 7 | """ 8 | 解压函数 9 | """ 10 | try: 11 | zFile.extractall(pwd=password.encode('utf-8')) 12 | print('[+] Password = ' + password + '\n') 13 | return True 14 | except: 15 | return 16 | def main(): 17 | 18 | parser = optparse.OptionParser("usage:" + "-f -d ") 19 | parser.add_option('-f', dest='zname', type='string', help='specify zip file') 20 | parser.add_option('-d', dest='dname', type='string', help='Password dictionary') 21 | 22 | (options, args) = parser.parse_args() 23 | 24 | if(options.zname == None) | (options.dname == None): 25 | print(parser.usage) 26 | exit(0) 27 | else: 28 | zname = options.zname 29 | dname = options.dname 30 | zFile = zipfile.ZipFile(zname) 31 | try: 32 | passFile = open(dname, 'r', ) 33 | with open(dname, 'r', encoding = 'utf-8') as passFile: 34 | for line in passFile.readlines(): 35 | password = line.strip('\n') 36 | flag = extractFile(zFile, password) 37 | if flag: 38 | print('爆破成功') 39 | break 40 | except Exception: 41 | print('错误输入') 42 | 43 | if __name__ == '__main__': 44 | main() --------------------------------------------------------------------------------