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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classZipPassword.BruteForceJobJob for performing brute force attack in paralle.
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_CHARSthe default characters.protected Stringm_Charactersthe characters to use for brute force.protected PlaceholderFilem_Dictionarythe dictionary file to use.protected PausableFixedThreadPoolExecutorm_Executorthe executor service to use for parallel execution.protected booleanm_Finishedwhether the search has terminated.protected List<ZipPassword.BruteForceJob>m_Jobsthe brute force jobs.protected intm_MaxLengththe maximum length for passwords to test.protected intm_NumThreadsthe number of threads to use for parallel execution.protected PlaceholderFilem_Passwordthe file to store the determined password in (if successful).protected Stringm_Startthe starting password.protected PlaceholderFilem_Zipthe zip file to use.-
Fields inherited from class adams.tools.AbstractTool
m_Stopped
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description ZipPassword()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcharactersTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.StringdictionaryTipText()Returns the tip text for this property.protected voiddoRun()Contains the actual run code.protected voiddoRunBruteForce()Performs brute force attack.protected voiddoRunDictionary()Uses dictionary for attak.StringgetCharacters()Returns the characters to use for brute force attack.PlaceholderFilegetDictionary()Returns the dictionary file to use.intgetMaxLength()Returns the maximum length of password string to generate for brute force attack.intgetNumThreads()Returns the number of threads to use for executing the branches.PlaceholderFilegetPassword()Returns the file for outputting the password.StringgetStart()Returns the starting password for the brute force attack.PlaceholderFilegetZip()Returns the ZIP file to use.StringglobalInfo()Returns a string describing the object.static voidmain(String[] args)Runs the tool from commandline.StringmaxLengthTipText()Returns the tip text for this property.StringnumThreadsTipText()Returns the tip text for this property.protected voidoutputPassword(String password)Outputs the password.StringpasswordTipText()Returns the tip text for this property.protected voidpreRun()Before the actual run is executed.voidsetCharacters(String value)Sets the characters to use for brute force attack.voidsetDictionary(PlaceholderFile value)Sets the dictionary file to use.voidsetMaxLength(int value)Sets the maximum length of password string to generate for brute force attack.voidsetNumThreads(int value)Sets the number of threads to use for executing the branches.voidsetPassword(PlaceholderFile value)Sets the file for outputting the password.voidsetStart(String value)Sets the starting password for the brute force attack.voidsetZip(PlaceholderFile value)Sets the ZIP file to use.StringstartTipText()Returns the tip text for this property.voidstopExecution()Stops the execution.StringzipTipText()Returns the tip text for this property.-
Methods inherited from class adams.tools.AbstractTool
cleanUp, compareTo, destroy, equals, forCommandLine, forName, getTools, isStopped, postRun, run, runTool
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
DEFAULT_CHARS
public static final String DEFAULT_CHARS
the default characters.- See Also:
- Constant Field Values
-
m_Zip
protected PlaceholderFile m_Zip
the zip file to use.
-
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.
-
m_Executor
protected PausableFixedThreadPoolExecutor m_Executor
the executor service to use for parallel execution.
-
m_Jobs
protected List<ZipPassword.BruteForceJob> m_Jobs
the brute force jobs.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractOptionHandler
-
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:
setNumThreadsin interfaceThreadLimiter- 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:
getNumThreadsin interfaceThreadLimiter- 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:
preRunin classAbstractTool
-
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:
doRunin classAbstractTool
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecutionin interfaceStoppable- Overrides:
stopExecutionin classAbstractTool
-
-