Python zip file password blasting

Source: Internet
Author: User

#!/usr/bin/env#Coding=utf-8ImportZipFileImportThreadingImportOSImportSYSclassCrackzip:def __init__(self): Self._result=NonedefRun (Self,zfile,password):Try: Zfile.extractall (pwd=password)Print("Found Passwd:", password)Print('password=', password) self._result=Passwordexcept:            Pass    defGetpass (self):returnSelf._resultdefcheckfile (PATH): Flag=Falseif  notos.path.isfile (PATH): Flag=FalsePrint('[-]%s file does not exist', Path)returnFlagdefMain (): CZ=Crackzip ()ifLen (SYS.ARGV) >=3: Zippath=sys.argv[1] Dictionarypath=sys.argv[2] Flag= (len (sys.argv) >3 andsys.argv[3]=='- T') TypeName=Noneif  notcheckfile (dictionarypath):ifdictionarypath[-3:]!='txt':                Print('dictionary is not a txt file')                return        if  notcheckfile (zippath):ifzippath[-3:]!='Zip':                Print('can only blast zip files')                returnZfile=zipfile. ZipFile ('Test.zip','R') Passfile=open (Dictionarypath,'R')         forLineinchpassfile.readlines (): Password=line.strip ('\ n'). Encode ('Utf-8')            ifFlag:false T=threading. Thread (target=cz.run,args=(Zfile,password)) T.start ()Else: Cz.run (zfile,password) password=Cz.getpass () typeName='Singlethread'                ifPassword:return        iftypename=='Singlethread':            Print("I can't find the password in the dictionary.")    Else:        Print('the command is not correct in the format: Python zip.py zippath dictionarypath')        returnif __name__=='__main__': Main ()

The following issues were encountered:

1. The characters obtained in the dictionary need to be encoded (UTF-8) to be recognized by Extractall

2. How do I detect all threads after the thread burst is turned on? (indicates that the blasting failed)

Python zip file password blasting

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.