2006-01-13 19:57:25 +03:00
|
|
|
#!/usr/bin/perl -wT
|
2004-10-08 05:06:46 +04:00
|
|
|
if (!defined $ARGV[0]) {
|
|
|
|
print "Usage: trapdoor PASSWORD\n";
|
|
|
|
exit 2;
|
|
|
|
}
|
2007-01-02 20:38:33 +03:00
|
|
|
|
|
|
|
# The following code was taking from Bugzilla's bz_crypt() subroutine
|
|
|
|
|
|
|
|
# The list of characters that can appear in a salt. Salts and hashes
|
|
|
|
# are both encoded as a sequence of characters from a set containing
|
|
|
|
# 64 characters, each one of which represents 6 bits of the salt/hash.
|
|
|
|
# The encoding is similar to BASE64, the difference being that the
|
|
|
|
# BASE64 plus sign (+) is replaced with a forward slash (/).
|
|
|
|
my @saltchars = (0..9, 'A'..'Z', 'a'..'z', '.', '/');
|
|
|
|
|
|
|
|
# Generate the salt. We use an 8 character (48 bit) salt for maximum
|
|
|
|
# security on systems whose crypt uses MD5. Systems with older
|
|
|
|
# versions of crypt will just use the first two characters of the salt.
|
|
|
|
my $salt = '';
|
|
|
|
|
|
|
|
for ( my $i=0 ; $i < 8 ; ++$i ) {
|
|
|
|
$salt .= $saltchars[rand(64)];
|
|
|
|
}
|
|
|
|
|
|
|
|
# Crypt the password.
|
|
|
|
print crypt($ARGV[0], $salt) . "\n";
|