Skip to content

Commit

Permalink
fix: increase challenge difficulty to 4
Browse files Browse the repository at this point in the history
  • Loading branch information
natesales committed Jul 9, 2022
1 parent 19e2359 commit cb0064d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions httpgate/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,19 @@ <h1>Checking your browser before accessing<br><b>example.com</b></h1>
</body>

<script defer>
async function sha256hash(plain) {
const encoder = new TextEncoder();
let hash_buf = await window.crypto.subtle.digest("SHA-256", encoder.encode(plain));
return [...new Uint8Array(hash_buf)].map(x => x.toString(16).padStart(2, '0')).join('');
}

const randHex = size => [...Array(size)].map(() => Math.floor(Math.random() * 16).toString(16)).join('').toString();

async function find_hash(hash) {
while (true) {
let token = randHex(32)
const encoder = new TextEncoder();
let hash_buf = await window.crypto.subtle.digest("SHA-256", encoder.encode(hash + token));
let hash_str = [...new Uint8Array(hash_buf)].map(x => x.toString(16).padStart(2, '0')).join('');
if (hash_str.endsWith("0".repeat(3))) {
let hash_str = await sha256hash(hash + token);
if (hash_str.endsWith("0".repeat(4))) {
return token;
}
}
Expand Down

0 comments on commit cb0064d

Please sign in to comment.