From owner-freebsd-questions Fri Dec 28 6:21:37 2001 Delivered-To: freebsd-questions@freebsd.org Received: from spliff.pangeia.com.br (spliff.pangeia.com.br [200.239.53.35]) by hub.freebsd.org (Postfix) with ESMTP id B310A37B417 for ; Fri, 28 Dec 2001 06:21:27 -0800 (PST) Received: by spliff.pangeia.com.br (Postfix, from userid 505) id 8AF253D3E1; Fri, 28 Dec 2001 12:21:26 -0200 (EDT) Date: Fri, 28 Dec 2001 12:21:26 -0200 From: Nelson Murilo To: Roberto Ruffinengo Cc: freebsd-questions@FreeBSD.ORG Subject: Re: crypted password length (crypt algorithm) Message-ID: <20011228122126.H23646@pangeia.com.br> References: <3C2C8AD7.25881.14F63B5@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3C2C8AD7.25881.14F63B5@localhost>; from r.ruffinengo@teoresi.it on Fri, Dec 28, 2001 at 03:08:07PM +0100 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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