我正在尝试制作一个nocatsplash页面 - 它使用HTML代码来检查密码并在输入正确的密码时重定向访问者

I am trying to make a nocatsplash page- it uses HTML code to check a password and redirect visitors if a correct password is entered

本文关键字:密码 检查 HTML 代码 重定向 访问者 输入 页面 nocatsplash 一个      更新时间:2023-09-26

我目前有一个工作代码,允许用户在单击按钮接受条款后通过。我想集成一个密码字段和接受按钮,只有在密码正确的情况下才允许某人通过。

这是我当前带有简单按钮的工作代码:

Agree to Connect:
<br>
<br>
<form method="post" id="login" action="http://10.0.0.1:5280/">
<input type="hidden" name="accept_terms" value="yes">
<input type="hidden" name="redirect" value="http://www.anderson1216.com/wifi-success.html">
<input type="hidden" name="mode_login">
<input type="submit" value="Accept Terms of Use and Connect">
</form>
<br>
//agreement text here
<br>
<br>
We thank you for your understanding and cooperation.
<br>
<br>
<form method="post" id="login" action="http://10.0.0.1:5280/">
<input type="hidden" name="accept_terms" value="yes">
<input type="hidden" name="redirect" value="http://www.anderson1216.com/wifi-success.html">
<input type="hidden" name="mode_login">
<input type="submit" value="Accept Terms of Use and Connect">
</form>

这是我找到的一个简单的密码表单:

<head>
<script type="text/javascript">
function isValid(){
var password = document.getElementById('password').value;
if (password == "password123")
{alert('Correct!')
else
{alert('Wrong Password')}
}
</script>
</head>
<form name="PasswordField" action="">
Password:
<input type="password" id="password" name="password">
<input type="button" value="Log in" onclick="isValid();">
</form>

为了使代码正常工作,需要将第一个代码块中的第一个语句包含在某处,以告诉路由器该人接受了,然后我希望它在他们单击按钮后重定向到另一个网站。正确的密码不需要警报,只需要不正确的密码。有什么建议吗?

我会认真地建议不要在js中列出密码!!任何查看源代码的人都可以看到这一点。您需要实现一个更安全的密码系统,其中包含保存在安全数据库中的散列和加盐密码,并通过 AJAX 调用或 PHP 进行检查。

看起来您想将其放在家用路由器上,可能作为登录页面? 如果你能详细说明一点,我也许能够提供更多的帮助。

如果您试图阻止某人访问该网站,除非他们知道秘密密码,那么这不是解决问题的方法。 您可能希望在服务器端而不是客户端对用户进行身份验证,因为任何对 JavaScript 了解有限的人都可以使用开发人员控制台在客户端进行欺骗身份验证。

但是,如果您只是想通过输入任意已知密码来确保人类同意协议条款,那么此方法就可以了。

为了安全起见,我同意上面的 gavrig 对它们进行哈希和加盐。

但是,如果我答对了你的问题,这是我整理的小提琴来解决它。我故意混合了jquery和javascript。

Agree to Connect:
<br>
<br>
//agreement text here
<br>
<br>
We thank you for your understanding and cooperation.
<br>
<br>
<form method="post" id="login" action="http://10.0.0.1:5280/">
<input type="password" id="password" name="password">
<input type="hidden" name="accept_terms" value="yes">
<input type="hidden" name="redirect" value="http://www.anderson1216.com/wifi-success.html">
<input type="hidden" name="mode_login">
<input type="submit" value="Accept Terms of Use and Connect">
</form>
$('form').on('submit', function(e){
    e.preventDefault();
  var password = document.getElementById('password').value;
        if (password == "password123")
        {
            this.submit();
        } 
    else
        {
            alert('Wrong Password');
        }
});

https://jsfiddle.net/tL7qcc5n/2/

NoCatSplash 不支持身份验证。任何用户都可以通过手动发布到 http://10.0.0.1:5280/来绕过您的身份验证

如果您认真对待身份验证,则应使用其他方法,例如使用 Radius 服务器。这甚至可以安装在路由器本身上,因为它有足够好的硬件来支持它。