Handle DES passwords

This commit is contained in:
Hervé BRY 2016-04-22 16:30:27 +02:00
parent 5e861eb78f
commit ea22b393ca
2 changed files with 23 additions and 7 deletions

View file

@ -49,13 +49,24 @@ fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Parsing user's salt # Parsing user's salt
shadow=$(grep "^$user:" /etc/shadow) shadow=$(grep "^$user:" /etc/shadow | cut -f 2 -d :)
salt=$(echo "$shadow" |cut -f 3 -d \$)
method=$(echo "$shadow" |cut -f 2 -d \$) if echo "$shadow" | grep -qE '^\$[0-9a-z]+\$[^\$]+\$'
if [ "$method" -eq '1' ]; then then
method='md5' salt=$(echo "$shadow" |cut -f 3 -d \$)
method=$(echo "$shadow" |cut -f 2 -d \$)
if [ "$method" -eq '1' ]; then
method='md5'
elif [ "$method" -eq '6' ]; then
method='sha-512'
else
echo "Error: password missmatch"
echo "$DATE $TIME $user $ip failed to login" >> $VESTA/log/auth.log
exit 9
fi
else else
method='sha-512' salt=${shadow:0:2}
method='des'
fi fi
if [ -z "$salt" ]; then if [ -z "$salt" ]; then
@ -64,7 +75,7 @@ if [ -z "$salt" ]; then
exit 9 exit 9
fi fi
# Generating SHA-512 # Generating hash
hash=$($BIN/v-generate-password-hash $method $salt <<< $password) hash=$($BIN/v-generate-password-hash $method $salt <<< $password)
if [[ -z "$hash" ]]; then if [[ -z "$hash" ]]; then
echo "Error: password missmatch" echo "Error: password missmatch"

View file

@ -37,5 +37,10 @@ if ($crypt == 'htpasswd' ) {
$hash = crypt($password, base64_encode($password)); $hash = crypt($password, base64_encode($password));
} }
// Generating DES hash
if ($crypt == 'des' ) {
$hash = crypt($password, $salt);
}
// Printing result // Printing result
echo $hash . "\n"; echo $hash . "\n";