working base
This commit is contained in:
parent
e090b70dba
commit
616c17501a
11 changed files with 1142 additions and 243 deletions
|
|
@ -8,10 +8,42 @@
|
|||
<body>
|
||||
<h1>Fighting crawlers</h1>
|
||||
<script type="text/javascript">
|
||||
/*setTimeout(function() {
|
||||
document.cookie = "mesozoa=1234; max-age=3600";
|
||||
const target_zeros = 15;
|
||||
const sha256 = async (input) => {
|
||||
const input_buf = new TextEncoder().encode(input);
|
||||
const output_buf = await window.crypto.subtle.digest("SHA-256", input_buf);
|
||||
return new Uint8Array(output_buf);
|
||||
};
|
||||
function verify_hash(hash) {
|
||||
return Math.clz32((hash[0] << 24) | (hash[1] << 16) | (hash[2] << 8) | hash[3]) >= target_zeros;
|
||||
}
|
||||
function get_cookie(name) {
|
||||
const value = "; "+document.cookie;
|
||||
const parts = value.split("; "+name+"=");
|
||||
return parts.pop().split(";").shift();
|
||||
}
|
||||
function submit_proof(proof) {
|
||||
document.cookie = "mesozoa-proof="+proof+"; domain=127.0.0.1; path=/; max-age=3600; samesite=strict";
|
||||
window.location.reload();
|
||||
}, 1000);*/
|
||||
}
|
||||
function timeout(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
async function pow(seed, nonce) {
|
||||
var stop = nonce + 1000;
|
||||
for(; nonce < stop; nonce ++) {
|
||||
if(verify_hash(await sha256(("00000000"+nonce).slice(-8)+seed))) {
|
||||
console.log(await sha256(("00000000"+nonce).slice(-8)+seed));
|
||||
console.log(("00000000"+nonce).slice(-8));
|
||||
submit_proof(("00000000"+nonce).slice(-8));
|
||||
return;
|
||||
}
|
||||
}
|
||||
setTimeout(function() {
|
||||
pow(seed, nonce);
|
||||
}, 0);
|
||||
}
|
||||
pow(get_cookie("mesozoa-challenge"), 0);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue