Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Dec 2001 12:21:26 -0200
From:      Nelson Murilo <nelson@pangeia.com.br>
To:        Roberto Ruffinengo <r.ruffinengo@teoresi.it>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: crypted password length (crypt algorithm)
Message-ID:  <20011228122126.H23646@pangeia.com.br>
In-Reply-To: <3C2C8AD7.25881.14F63B5@localhost>; from r.ruffinengo@teoresi.it on Fri, Dec 28, 2001 at 03:08:07PM %2B0100
References:  <3C2C8AD7.25881.14F63B5@localhost>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Dec 28, 2001 at 03:08:07PM +0100, Roberto Ruffinengo wrote:
> Hi everybody,
> 
> I  am running a FreeBSD 4.3 box
> 
> and i think i have found something interesting.
> 
> On older version of FreeBSD I had a perl script to verify users login account 
> that was working quite well.
> 
> I  moved it on my 4.3 release and it doesn't work at all.
> 
> In fact the perl crypt()  function generates a  crypted password  which is  13 
> char long, while the password in /etc/master.passwd is  34 char long.
 

crypt can generate DES or MD5 paswords, if you include '$1$' in
salt, crypt generate MD5.

Like this:

#!/usr/bin/perl
# (C) Nelson Murilo - nelson@pangeia.com.br
# Fri Dec 28 11:47:20 BRST 2001 $nmor
sub salt {
    local($salt);		# initialization
    local($i, $rand);
    local(@itoa64) = ( '0' .. '9', 'a' .. 'z', 'A' .. 'Z' ); # 0 .. 63

    # to64
    for ($i = 0; $i < 27; $i++) {
	srand(time + $rand + $$); 
	$rand = rand(25*29*17 + $rand);
	$salt .=  $itoa64[$rand & $#itoa64];
    }
    $salt = '$1$'.$salt;
    return $salt;
}

## Main
#
$cryptpwd = "";
$password = $ARGV[0];
$cryptpwd = crypt($password, &salt) if $password ne "";
print "$cryptpwd\n";


Hope this help,

./nelson -murilo

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011228122126.H23646>