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 class
ZipPassword.BruteForceJob
Job for performing brute force attack in paralle.
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_CHARS
the default characters.protected String
m_Characters
the characters to use for brute force.protected PlaceholderFile
m_Dictionary
the dictionary file to use.protected PausableFixedThreadPoolExecutor
m_Executor
the executor service to use for parallel execution.protected boolean
m_Finished
whether the search has terminated.protected List<ZipPassword.BruteForceJob>
m_Jobs
the brute force jobs.protected int
m_MaxLength
the maximum length for passwords to test.protected int
m_NumThreads
the number of threads to use for parallel execution.protected PlaceholderFile
m_Password
the file to store the determined password in (if successful).protected String
m_Start
the starting password.protected PlaceholderFile
m_Zip
the 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 String
charactersTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.String
dictionaryTipText()
Returns the tip text for this property.protected void
doRun()
Contains the actual run code.protected void
doRunBruteForce()
Performs brute force attack.protected void
doRunDictionary()
Uses dictionary for attak.String
getCharacters()
Returns the characters to use for brute force attack.PlaceholderFile
getDictionary()
Returns the dictionary file to use.int
getMaxLength()
Returns the maximum length of password string to generate for brute force attack.int
getNumThreads()
Returns the number of threads to use for executing the branches.PlaceholderFile
getPassword()
Returns the file for outputting the password.String
getStart()
Returns the starting password for the brute force attack.PlaceholderFile
getZip()
Returns the ZIP file to use.String
globalInfo()
Returns a string describing the object.static void
main(String[] args)
Runs the tool from commandline.String
maxLengthTipText()
Returns the tip text for this property.String
numThreadsTipText()
Returns the tip text for this property.protected void
outputPassword(String password)
Outputs the password.String
passwordTipText()
Returns the tip text for this property.protected void
preRun()
Before the actual run is executed.void
setCharacters(String value)
Sets the characters to use for brute force attack.void
setDictionary(PlaceholderFile value)
Sets the dictionary file to use.void
setMaxLength(int value)
Sets the maximum length of password string to generate for brute force attack.void
setNumThreads(int value)
Sets the number of threads to use for executing the branches.void
setPassword(PlaceholderFile value)
Sets the file for outputting the password.void
setStart(String value)
Sets the starting password for the brute force attack.void
setZip(PlaceholderFile value)
Sets the ZIP file to use.String
startTipText()
Returns the tip text for this property.void
stopExecution()
Stops the execution.String
zipTipText()
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:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in 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:
setNumThreads
in 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:
getNumThreads
in 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:
preRun
in 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:
doRun
in classAbstractTool
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceStoppable
- Overrides:
stopExecution
in classAbstractTool
-
-