Das Passwort wird mittels Perl über die Funktion crypt erstellt.
Ja. Und genau das ist der Fehler. crypt benutzt sha1 ohne Salt welches sogar unsicherer als die Apache-eigene, schwache und schwach gesalzene Implementation von MD5 ist.
Sowas könnte Abhilfe schaffen, wird aber nicht jedem gefallen:
sub htpasswd_wrapper {
## return a fin hashed password for Apache 2.4 oder 2.2
## usage htpasswd_wrapper($passwd_clear, '2.4') or usage htpasswd_wrapper($passwd_clear, '2.2')
my $passwd_clear = shift;
$passwd_clear =~ s/\"/\\\"/g;
$passwd_clear =~ s/\`/\\\`/g;
my $version = shift;
my $sys; my $passwd_hash;
if ( $version eq "2.2" ) {
$sys = "echo \"$passwd_clear\" | /usr/bin/htpasswd -i -n \"USER\";";
print $sys;
} elsif ( $version eq "2.4" ) {
$sys = "echo \"$passwd_clear\" | /usr/bin/htpasswd -i -n -B \"USER\";";
print $sys;
} else {
$sys=false;
}
if ($sys) {
$passwd_hash = `$sys`;
$passwd_hash =~ s/^USER://;
return $passwd_hash;
} else {
return false;
}
}
$passwd_hash = htpasswd_wrapper("ha'llo", '2.4');
print $passwd_hash . "\n";
$passwd_hash = htpasswd_wrapper('ha"llo', '2.4');
print $passwd_hash . "\n";
$passwd_hash = htpasswd_wrapper('ha`ll`o', '2.4');
print $passwd_hash . "\n";