Compare commits
3 commits
7308344d01
...
9cfe64915d
Author | SHA1 | Date | |
---|---|---|---|
9cfe64915d | |||
1c2cfb63cb | |||
f510fc7f5d |
3 changed files with 101 additions and 2 deletions
|
@ -1,7 +1,11 @@
|
|||
package ch.kousz.adrian.encfs;
|
||||
|
||||
import ch.kousz.adrian.util.LineIterable;
|
||||
import ch.kousz.adrian.util.StringGenerator;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import org.mrpdaemon.sec.encfs.EncFSBinaryConfig;
|
||||
import org.mrpdaemon.sec.encfs.EncFSConfig;
|
||||
import org.mrpdaemon.sec.encfs.EncFSConfigParser;
|
||||
|
@ -12,14 +16,30 @@ public class EncFSBrute
|
|||
public static void main(String[] args)
|
||||
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 charset = args[1];
|
||||
int minLength = Integer.parseInt(args[2]);
|
||||
String param = 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));
|
||||
EncFSBinaryConfig binaryConfig = EncFSBinaryConfig.from(config);
|
||||
|
||||
for (String pw: new StringGenerator(charset, minLength)) {
|
||||
for (String pw: passwordGenerator) {
|
||||
System.err.println("Trying: " + pw);
|
||||
boolean ok = EncFSUtil.checkPassword(binaryConfig, pw);
|
||||
if (ok) {
|
||||
|
|
63
src/ch/kousz/adrian/util/LineIterable.java
Normal file
63
src/ch/kousz/adrian/util/LineIterable.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
16
src/ch/kousz/adrian/util/Throwables.java
Normal file
16
src/ch/kousz/adrian/util/Throwables.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
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
Reference in a new issue