Created
June 21, 2019 09:41
-
-
Save wknapik/6f45dfbbdc5bacb84290fed12d7a2f5d to your computer and use it in GitHub Desktop.
Verify whether a hash generated with htpasswd matches a password
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% htpasswd -nb foo bar >passwd | |
% ./chkpasswd.exp passwd foo bar | |
% echo "$?" | |
# 0 = match, 1 = no match |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env expect | |
log_user 0 | |
set file [lindex $argv 0] | |
set user [lindex $argv 1] | |
set password [lindex $argv 2] | |
spawn htpasswd -v $file $user | |
expect "Enter password: " | |
send "$password\r" | |
expect "Password for user $user correct." { exit 0 } | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment