Package adams.tools

Class ZipPassword

  • All Implemented Interfaces:
    CleanUpHandler, Destroyable, GlobalInfoSupporter, LoggingLevelHandler, LoggingSupporter, OptionHandler, SizeOfHandler, Stoppable, StoppableWithFeedback, ThreadLimiter, Serializable, Comparable

    public class ZipPassword
    extends AbstractTool
    implements ThreadLimiter
    Attempts to determine the password of a password protected ZIP file.
    If no dictionary file has been provided, a brute force attack is carried out.
    The brute force attack can be run in parallel, default is two threads.
    The dictionary approach also tests lower/upper case version of the passwords and the reverse of them.

    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
     
    -zip <adams.core.io.PlaceholderFile> (property: zip)
        The ZIP file to process.
        default: ${CWD}
     
    -dictionary <adams.core.io.PlaceholderFile> (property: dictionary)
        The dictionary file to process.
        default: ${CWD}
     
    -chars <java.lang.String> (property: characters)
        The characters to use for brute force attack.
        default: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,;:\'\"-_!@#$%^&*()[]{}
     
    -max-length <int> (property: maxLength)
        The maximum length for password strings when performing brute force attack.
        default: 10
        minimum: 1
     
    -start <java.lang.String> (property: start)
        The starting password for the brute force attack.
        default: 
     
    -num-threads <int> (property: numThreads)
        The number of threads to use for parallel execution; > 0: specific number 
        of cores to use (capped by actual number of cores available, 1 = sequential 
        execution); = 0: number of cores; < 0: number of free cores (eg -2 means 
        2 free cores; minimum of one core is used)
        default: 2
     
    -password <adams.core.io.PlaceholderFile> (property: password)
        The file to store the password in (if one found).
        default: ${CWD}
     
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_Dictionary

        protected PlaceholderFile m_Dictionary
        the dictionary file to use.
      • m_Characters

        protected String m_Characters
        the characters to use for brute force.
      • m_MaxLength

        protected int m_MaxLength
        the maximum length for passwords to test.
      • m_Start

        protected String m_Start
        the starting password.
      • m_NumThreads

        protected int m_NumThreads
        the number of threads to use for parallel execution.
      • m_Password

        protected PlaceholderFile m_Password
        the file to store the determined password in (if successful).
      • m_Finished

        protected boolean m_Finished
        whether the search has terminated.
    • Constructor Detail

      • ZipPassword

        public ZipPassword()
    • Method Detail

      • setZip

        public void setZip​(PlaceholderFile value)
        Sets the ZIP file to use.
        Parameters:
        value - the zip file
      • getZip

        public PlaceholderFile getZip()
        Returns the ZIP file to use.
        Returns:
        the zip file
      • zipTipText

        public String zipTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setDictionary

        public void setDictionary​(PlaceholderFile value)
        Sets the dictionary file to use.
        Parameters:
        value - the dictionary file
      • getDictionary

        public PlaceholderFile getDictionary()
        Returns the dictionary file to use.
        Returns:
        the dictionary file
      • dictionaryTipText

        public String dictionaryTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setCharacters

        public void setCharacters​(String value)
        Sets the characters to use for brute force attack.
        Parameters:
        value - the characters
      • getCharacters

        public String getCharacters()
        Returns the characters to use for brute force attack.
        Returns:
        the characters
      • charactersTipText

        public String charactersTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setMaxLength

        public void setMaxLength​(int value)
        Sets the maximum length of password string to generate for brute force attack.
        Parameters:
        value - the maximum length
      • getMaxLength

        public int getMaxLength()
        Returns the maximum length of password string to generate for brute force attack.
        Returns:
        the maximum length
      • maxLengthTipText

        public String maxLengthTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setStart

        public void setStart​(String value)
        Sets the starting password for the brute force attack.
        Parameters:
        value - the starting password
      • getStart

        public String getStart()
        Returns the starting password for the brute force attack.
        Returns:
        the starting password
      • startTipText

        public String startTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setNumThreads

        public void setNumThreads​(int value)
        Sets the number of threads to use for executing the branches.
        Specified by:
        setNumThreads in interface ThreadLimiter
        Parameters:
        value - the number of threads: -1 = # of CPUs/cores; 0/1 = sequential execution
      • getNumThreads

        public int getNumThreads()
        Returns the number of threads to use for executing the branches.
        Specified by:
        getNumThreads in interface ThreadLimiter
        Returns:
        the number of threads: -1 = # of CPUs/cores; 0/1 = sequential execution
      • numThreadsTipText

        public String numThreadsTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setPassword

        public void setPassword​(PlaceholderFile value)
        Sets the file for outputting the password.
        Parameters:
        value - the password file
      • getPassword

        public PlaceholderFile getPassword()
        Returns the file for outputting the password.
        Returns:
        the password file
      • passwordTipText

        public String passwordTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • preRun

        protected void preRun()
        Before the actual run is executed. Default implementation only resets the stopped flag.
        Overrides:
        preRun in class AbstractTool
      • doRunBruteForce

        protected void doRunBruteForce()
        Performs brute force attack.
      • doRunDictionary

        protected void doRunDictionary()
        Uses dictionary for attak.
      • outputPassword

        protected void outputPassword​(String password)
        Outputs the password.
        Parameters:
        password - the password, null if failed to determine
      • doRun

        protected void doRun()
        Contains the actual run code.
        Specified by:
        doRun in class AbstractTool
      • main

        public static void main​(String[] args)
                         throws Exception
        Runs the tool from commandline.
        Parameters:
        args - the parameters
        Throws:
        Exception - if anything goes wrong