File tree Expand file tree Collapse file tree 2 files changed +23
-7
lines changed
Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Original file line number Diff line number Diff line change 4949# ----------------------------------------------------------#
5050
5151# Parsing user's salt
52- shadow=$( grep " ^$user :" /etc/shadow)
53- salt=$( echo " $shadow " | cut -f 3 -d \$ )
54- method=$( echo " $shadow " | cut -f 2 -d \$ )
55- if [ " $method " -eq ' 1' ]; then
56- method=' md5'
52+ shadow=$( grep " ^$user :" /etc/shadow | cut -f 2 -d :)
53+
54+ if echo " $shadow " | grep -qE ' ^\$[0-9a-z]+\$[^\$]+\$'
55+ then
56+ salt=$( echo " $shadow " | cut -f 3 -d \$ )
57+ method=$( echo " $shadow " | cut -f 2 -d \$ )
58+ if [ " $method " -eq ' 1' ]; then
59+ method=' md5'
60+ elif [ " $method " -eq ' 6' ]; then
61+ method=' sha-512'
62+ else
63+ echo " Error: password missmatch"
64+ echo " $DATE $TIME $user $ip failed to login" >> $VESTA /log/auth.log
65+ exit 9
66+ fi
5767else
58- method=' sha-512'
68+ salt=${shadow: 0: 2}
69+ method=' des'
5970fi
6071
6172if [ -z " $salt " ]; then
@@ -64,7 +75,7 @@ if [ -z "$salt" ]; then
6475 exit 9
6576fi
6677
67- # Generating SHA-512
78+ # Generating hash
6879hash=$( $BIN /v-generate-password-hash $method $salt <<< $password )
6980if [[ -z " $hash " ]]; then
7081 echo " Error: password missmatch"
Original file line number Diff line number Diff line change @@ -37,5 +37,10 @@ if ($crypt == 'htpasswd' ) {
3737 $ hash = crypt ($ password , base64_encode ($ password ));
3838}
3939
40+ // Generating DES hash
41+ if ($ crypt == 'des ' ) {
42+ $ hash = crypt ($ password , $ salt );
43+ }
44+
4045// Printing result
4146echo $ hash . "\n" ;
You can’t perform that action at this time.
0 commit comments