49 lines
1.4 KiB
HTML
49 lines
1.4 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8"/>
|
|
<meta name="robots" content="noindex"/>
|
|
<title>Antispam working...</title>
|
|
</head>
|
|
<body>
|
|
<h1>Fighting crawlers</h1>
|
|
<script type="text/javascript">
|
|
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();
|
|
}
|
|
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>
|