bunkerized-nginx/antibot/javascript.data
2021-05-19 17:36:29 +02:00

30 lines
836 B
Plaintext

<script>
async function digestMessage(message) {
const msgUint8 = new TextEncoder().encode(message);
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
return hashHex;
}
(async () => {
const nonce = '%s';
var i = 0;
while (true) {
var digestHex = await digestMessage(nonce + i.toString());
if (digestHex.startsWith("0000")) {
break;
}
i++;
}
xhr = new XMLHttpRequest();
xhr.open('POST', '%s');
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function() {
if (xhr.status === 200) {
window.location.replace('%s');
}
};
xhr.send(encodeURI('challenge=' + i.toString()));
})();
</script>