#!/usr/local/bin/perl # DES で crypt 済のパスワード $des_crypted_password = 'ABS5SGh1EL6bk'; # MD5 で crypt 済のパスワード $md5_crypted_password = '$1$AB$qHArPuqikDNZFVs6JTunC1'; $salt = 'AB'; print "Content-type: text/html\n\n"; print "
\n"; if ( $ENV{REQUEST_METHOD} eq 'POST' ){ read(STDIN,$buf,$ENV{CONTENT_LENGTH}); foreach ( split('&',$buf) ){ ($key,$value) = split('=',$_); $value =~ tr/+/ /; $value =~ s/%([0-9a-fA-F][0-9a-fA-F])/pack("C",hex($1))/eg; $FORM{$key} = $value; } print "crypt('$FORM{'password'}','$salt') =",crypt($FORM{'password'},$salt),"\n";
print "\$des_crypted_password = '$des_crypted_password'
\n";
print "\$md5_crypted_password = '$md5_crypted_password'
\n";
if ( crypt($FORM{'password'},$salt) eq $des_crypted_password ){
print "ユーザ認証 OK です。このホストの crypt 方式は DES です。\n";
} elsif ( crypt($FORM{'password'},$salt) eq $md5_crypted_password ){
print "ユーザ認証 OK です。このホストの crypt 方式は MD5 です。\n";
} else {
print "パスワードが違います。\n";
}
}
# 自分自身のファイル名を取得
$script_name = $ENV{SCRIPT_NAME};
$script_name =~ s|.*/([^/]+)$|$1|;
print <