国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

用戶口令檢查(/etc/passwd)

2024-05-04 23:05:03
字體:
來源:轉載
供稿:網友
<?
/*
* etc.passwd.inc v1.0
*
* syntax:
* verifypasswd(string username, string password)
*
* the function will return one of three values:
* -2 if there was a file reading error
* -1 if the password is incorrect
* 0 if the username doesn't exist
* 1 if the password is correct
*
* written by warmage ( [email protected] )
*
*/

function verifypasswd ($username, $password) {

$fd = fopen( "/etc/passwd", "r");
$contents = fread($fd, filesize( "/etc/passwd"));
fclose($fd);
if (!$contents) return -2;



$lines = split( "/n", $contents);
$passwd = array();

for($count=0;$count<count($lines);$count++) {
list ($user,$pass) = split( ":",$lines[$count]);
if ($user == $username) {
break;
}
}

if (!$user) return 0;

$cryptedpass = $pass;
$salt = substr($cryptedpass,0,2);
$pass = crypt($password,$salt);

if ($pass == $cryptedpass) {
return 1;
} else {
return -1;
}
}
?>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 准格尔旗| 红桥区| 临夏县| 子洲县| 余干县| 南开区| 辽阳市| 泰州市| 秭归县| 玉溪市| 会理县| 望谟县| 泌阳县| 平湖市| 文安县| 溧阳市| 抚顺市| 洛南县| 淳安县| 滦平县| 湘潭县| 平武县| 高安市| 婺源县| 新兴县| 汉中市| 保定市| 桦川县| 武邑县| 皮山县| 甘肃省| 福鼎市| 葫芦岛市| 鄂尔多斯市| 定日县| 京山县| 同仁县| 涿州市| 曲松县| 福泉市| 盈江县|