note 28763 deleted from function.crypt by aidan

From: Date: Mon, 05 Jul 2004 10:27:51 +0000
Subject: note 28763 deleted from function.crypt by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-72583@lists.php.net to get a copy of this message
Note Submitter: chrisw@ss.net.au ---- 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)

« previous php.notes (#72583) next »