【问题标题】:How to make a password system for challenges like rootme web [closed]如何为rootme web等挑战制作密码系统[关闭]
【发布时间】:2021-02-13 15:49:40
【问题描述】:

我正在创建一个您必须回答问题的网站。但答案并不安全。

我已经尝试过使用 Javascript Obfuscator,但我对这种方法并不满意(很容易破解)。我可以在哪里/如何存储这些答案?

我正在寻找一个类似 root-me 或一些挑战的系统。

如果您有任何建议或资源,请告诉我!

这是我的 Javascript 代码

var Answers = ['abc', 'abcd', 'abcde', 'abcdef']


function checkAnswers(){
    Student_answer = document.f1.studentAnswer.value;
    Teacher_answer = Answers[PageNum];

    if (Student_answer.length == 0 || Teacher_answer.length == 0) {
        Swal.fire ({
            position: 'center',
            icon: 'warning',
            title: 'You Must Enter An Answer',
            text: 'Try again',
            timer: 1500
        });
        return false;
    }
    if (Student_answer == Teacher_answer) {
        Swal.fire ({
            position: 'center',
            icon: 'success',
            title: 'Good Job!',
            text: 'Next anigma...',
            confirmButtonText: '<a href="index1.html" onclick="closepopup()" style="color:#d9d9d9; text-decoration:none">Next</a>',
          });
        } else {
            Swal.fire ({
                position: 'center',
                icon: 'error',
                title: 'Wrong Answer',
                text: 'Try again',
                timer: 1500
            });
        }
}

【问题讨论】:

    标签: javascript html passwords


    【解决方案1】:

    您可以存储答案的哈希值而不是明文答案本身。

    const answer = 'abc'
    const encoder = new TextEncoder();
    const data = encoder.encode(answer);
    const hash = await crypto.subtle.digest('SHA-256', data);
    

    当用户输入答案时,您将对他们的答案进行哈希处理,如果哈希与存储的哈希匹配,则答案是正确的。

    人们仍然可以通过在 Google 上查找散列来找到答案:为了防止在散列之前使用 R3pTgWu7gy4FsbH6 之类的随机字符串为所有答案添加前缀,或者使用消息验证码 (MAC) 函数对答案进行散列.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-07
      相关资源
      最近更新 更多