Compare commits
No commits in common. "9cfe64915d59f6af8d5d89b483c08ed4a92e13c8" and "7308344d015af0386aed8130bc0ed58fa76b0987" have entirely different histories.
9cfe64915d
...
7308344d01
3 changed files with 2 additions and 101 deletions
|
|
@ -1,11 +1,7 @@
|
||||||
package ch.kousz.adrian.encfs;
|
package ch.kousz.adrian.encfs;
|
||||||
|
|
||||||
import ch.kousz.adrian.util.LineIterable;
|
|
||||||
import ch.kousz.adrian.util.StringGenerator;
|
import ch.kousz.adrian.util.StringGenerator;
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import org.mrpdaemon.sec.encfs.EncFSBinaryConfig;
|
import org.mrpdaemon.sec.encfs.EncFSBinaryConfig;
|
||||||
import org.mrpdaemon.sec.encfs.EncFSConfig;
|
import org.mrpdaemon.sec.encfs.EncFSConfig;
|
||||||
import org.mrpdaemon.sec.encfs.EncFSConfigParser;
|
import org.mrpdaemon.sec.encfs.EncFSConfigParser;
|
||||||
|
|
@ -16,30 +12,14 @@ public class EncFSBrute
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
if (args.length < 3) {
|
|
||||||
System.out.println("USAGE: EncFSBrute <encfs xml path> <charset> <min length>");
|
|
||||||
System.out.println("or: EncFSBrute <encfs xml path> \"wordlist\" <wordlist path>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String filename = args[0];
|
String filename = args[0];
|
||||||
String charset = args[1];
|
String charset = args[1];
|
||||||
String param = args[2];
|
int minLength = Integer.parseInt(args[2]);
|
||||||
|
|
||||||
Iterable<String> passwordGenerator;
|
|
||||||
|
|
||||||
if ("wordlist".equals(charset)) {
|
|
||||||
BufferedReader rdr = new BufferedReader(new InputStreamReader(new FileInputStream(param), "UTF-8"));
|
|
||||||
passwordGenerator = new LineIterable(rdr);
|
|
||||||
} else {
|
|
||||||
int minLength = Integer.parseInt(param);
|
|
||||||
passwordGenerator = new StringGenerator(charset, minLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
EncFSConfig config = EncFSConfigParser.parseFile(new File(filename));
|
EncFSConfig config = EncFSConfigParser.parseFile(new File(filename));
|
||||||
EncFSBinaryConfig binaryConfig = EncFSBinaryConfig.from(config);
|
EncFSBinaryConfig binaryConfig = EncFSBinaryConfig.from(config);
|
||||||
|
|
||||||
for (String pw: passwordGenerator) {
|
for (String pw: new StringGenerator(charset, minLength)) {
|
||||||
System.err.println("Trying: " + pw);
|
System.err.println("Trying: " + pw);
|
||||||
boolean ok = EncFSUtil.checkPassword(binaryConfig, pw);
|
boolean ok = EncFSUtil.checkPassword(binaryConfig, pw);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
|
|
|
||||||
|
|
@ -1,63 +0,0 @@
|
||||||
package ch.kousz.adrian.util;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class LineIterable
|
|
||||||
implements Iterable<String>
|
|
||||||
{
|
|
||||||
private final BufferedReader rdr;
|
|
||||||
|
|
||||||
public LineIterable(BufferedReader rdr)
|
|
||||||
{
|
|
||||||
this.rdr = rdr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public java.util.Iterator<String> iterator()
|
|
||||||
{
|
|
||||||
return new LineIterable.Iterator(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Iterator
|
|
||||||
implements java.util.Iterator<String>
|
|
||||||
{
|
|
||||||
private final BufferedReader rdr;
|
|
||||||
private String next;
|
|
||||||
|
|
||||||
public Iterator(LineIterable gen)
|
|
||||||
{
|
|
||||||
this.rdr = gen.rdr;
|
|
||||||
readNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNext()
|
|
||||||
{
|
|
||||||
return next != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String next()
|
|
||||||
{
|
|
||||||
String result = next;
|
|
||||||
readNext();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove()
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void readNext()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
next = rdr.readLine();
|
|
||||||
} catch (IOException ex) {
|
|
||||||
throw Throwables.sneakyThrow(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
|
|
||||||
package ch.kousz.adrian.util;
|
|
||||||
|
|
||||||
public class Throwables
|
|
||||||
{
|
|
||||||
public static RuntimeException sneakyThrow(Throwable t)
|
|
||||||
{
|
|
||||||
Throwables.<RuntimeException>sneakyThrowNow(t);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private static <T extends Throwable> T sneakyThrowNow(Throwable t) throws T {
|
|
||||||
throw (T) t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue