I'm using the poorly documented Zip4j library for Java to create a program that runs dictionary attacks on locked zip files. When I run my program, it pulls values from a dictionary file and runs them by the zip to see if they work. If they do, the file is extracted. The part that's annoying me is that even if he properly extracts it, it continues to run passwords by it. I'd like it to stop upon successful extraction. How may I go about do this? How can I create a trigger where when the file is pulled from the zip the program stops trying to extract? Here's the loop I'm using:
if(zipper.isEncrypted()){
while(passwordCounter != passwordArray.size()){
zipper.setPassword((String) passwordArray.get(passwordCounter));
System.out.println("Testing password no." + passwordCounter + ", which is " + passwordArray.get(passwordCounter));
passwordCounter = passwordCounter + 1;
try {
zipper.extractAll(dest);
} catch(ZipException ze) {
continue;
}
}
} else
zipper.extractAll(dest);
P.S. The files contained within a zip are not always named the same thing as the zip, so you can't check for the existence of a folder named the same thing as the zip. Also, if the user wants the zip to go to their Desktop, for example, you can't say that if the size is not 0 then it has been extracted. Files will most likely be on their desktop.
Put a break;
under the zipper.extractAll(dest);
statement, but within the try-catch
try {
zipper.extractAll(dest);
break;
} catch(ZipException ze) {
continue;
}
This will cause the code to break out of the current loop