gpt4 book ai didi

php - 限制登录时删除非现有用户保存的失败尝试

转载 作者:行者123 更新时间:2023-11-30 22:20:08 24 4
gpt4 key购买 nike

限制登录,

是否有必要将一个不存在的用户的失败尝试插入到数据库中?如果不采取任何措施,则无法在对用户进行限制时猜出数据库中的现有用户名,而不是不存在的用户名,这不是安全风险吗?

如果有必要,在风险较低的情况下如何处理删除它们?

//If the username does not exist do the below:

<?php
$stmt= $conn->prepare('SELECT * from failed_logins WHERE name="'.$_SESSION["Name"].'"');
$stmt->bindParam(1, $name);
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC);
while($row = $stmt->fetch()) {
$attempted = $row['attempted'];
}
$atime = strtotime($attempted);
$current = time();
if(($current-$atime) > 1500) {
$del= $conn->query("DELETE FROM failed_logins WHERE name = '".$_SESSION['Name']."'");
$del->execute();
}
?>

最佳答案

从安全的角度来看,您绝对应该限制每个用户登录失败的次数。如果你不这样做,你是在认真地把你的网站暴露给 brute-force attacks .例如,在 3 次登录尝试失败后,根据用户的 IP 地址将用户锁定 24 小时。

例如,我不会为了您可能每 6 个月定期执行的取证调查而删除与失败登录尝试相关的任何数据。

关于php - 限制登录时删除非现有用户保存的失败尝试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36876893/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com