note 28763 added to function.crypt

From: Date: Thu, 23 Jan 2003 08:48:12 +0000
Subject: note 28763 added to function.crypt
Groups: php.notes 
Request: Send a blank email to php-notes+get-42634@lists.php.net to get a copy of this message
Hello, I just thought i would post this modified script. It will grab the user/pass from the passwd file in Linux/FreeBSD/basicly any unix system using md5. It will then compare the string to defined user/pass. $user = "user"; $pass = "pass"; $autharray = file("/etc/shadow"); for ($x = 0; $x < count($autharray); $x++) { if (eregi("^$user:", $autharray[$x])) { $passwd = explode(":", $autharray[$x]); $salt = substr($passwd[1],0,11); $cryptpw = crypt($pass,$salt); if ($cryptpw == $passwd[1]) { echo "Login ok"; } else { echo "Error login failed"; } } } Regards Chris W ( Niacin on EFnet) -- http://www.php.net/manual/en/function.crypt.php http://master.php.net/manage/user-notes.php?action=edit+28763 http://master.php.net/manage/user-notes.php?action=delete+28763 http://master.php.net/manage/user-notes.php?action=reject+28763

« previous php.notes (#42634) next »