我有一个 JavaScript 来检查是否输入了某个 4 位数代码:
verify = function (num, success) {
if (true && (num & Math.pow(2, 0)) == 0 && (num & Math.pow(2, 1)) != 0 && (num & Math.pow(2, 2)) == 0 && (num & Math.pow(2, 3)) != 0 && (num & Math.pow(2, 4)) == 0 && (num & Math.pow(2, 5)) == 0 && (num & Math.pow(2, 6)) == 0 && (num & Math.pow(2, 7)) != 0 && (num & Math.pow(2, 8)) == 0 && (num & Math.pow(2, 9)) == 0 && (num & Math.pow(2, 10)) != 0 && (num & Math.pow(2, 11)) != 0 && (num & Math.pow(2, 12)) != 0 && (num & Math.pow(2, 13)) == 0 && (num & Math.pow(2, 14)) == 0 && (num & Math.pow(2, 15)) == 0) {
setTimeout(success, 1000);
} else {
location.reload();
}
}
我如何反转它以找出它想要的数字? 不用担心,这是我工作中的黑客游戏:)
最佳答案
只要算一下就可以了。该代码是创建位掩码的一种极其丑陋的方式:
0b0001110010001010 是目标号码,即 7306。
编辑:话又说回来,代码也接受 0b10001110010001010,即 72842。任何具有指定的低 15 位的数字都可以被该算法接受。
关于Javascript反向验证输入代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20678483/