限制登录时删除非现有用户保存的失败尝试
Deleting saved failed attempts of the non existing users when throttling login
限制登录,
是否有必要将一个不存在的用户的失败尝试插入到数据库中?
如果不采取任何措施,那么在对数据库中的用户名进行限制而不是不存在的用户名时,有人无法猜测数据库中的现有用户名,这不是安全风险吗?
如果有必要,在风险较低的情况下如何处理删除它们?
//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 个月定期执行一次。
限制登录,
是否有必要将一个不存在的用户的失败尝试插入到数据库中? 如果不采取任何措施,那么在对数据库中的用户名进行限制而不是不存在的用户名时,有人无法猜测数据库中的现有用户名,这不是安全风险吗?
如果有必要,在风险较低的情况下如何处理删除它们?
//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 个月定期执行一次。