Saturday, May 26, 2007

Recovering of Encfs Password

Whew. I've found all forgotten passwords for encfs with a help of the perl script:


#!/usr/bin/perl

use strict;
use warnings;

# these words are used as password components
my @words = (
"example", " ", "word", "123", "666", "pwd", "part1"
);

my @l = ();

sub mindex {
my $x = shift;

for (my $i = 0; $i <= $#words; $i++) {
if ($words[$i] eq $x) {
return $i;
}
}

return -1;
};

sub inc {
my $p = shift;
my $v = $l[$p];

unless (defined $v) {
$l[$p] = $words[0];
} else {
my $i = mindex ($v);
if ($i == $#words) {
$l[$p] = $words[0];
inc ($p+1);
} else {
$l[$p] = $words[$i+1];
}
}
};

while (1) {
inc (0);
my @ll = reverse @l;
my $pwd = join '', @ll;

open F, ">/tmp/1233";
print F "pwd\n";
close F;

print "$pwd\n";
system "encfs -S /tmp/encfsdir /tmp/mountpoint < /tmp/1233";
}


You may use it if you still know a vague shape of password you have lost.

1 comment: