Tech

How I Built Undetectable Browser Automation with CSPRNG

A deep dive into the cryptographic random number generator and human-matched distributions that make the Crown Bot invisible to anti-bot systems.

June 27, 2026·10 min read·by Kevin

When I started building the Crown Bot for sweepstakes casino automation, the first problem wasn't the casino logic — it was detection. Anti-bot systems analyze behavioral patterns, and Math.random() creates predictable timing that gets you banned within hours.

The Math.random() Problem

JavaScript's Math.random() uses xorshift128+, a deterministic PRNG. From just a few outputs, you can reconstruct the entire sequence. Anti-bot systems exploit this to detect automation with near certainty.

⚠ WarningIf your automation uses Math.random() for delays, you're already detected. The distribution is uniform and the sequence is predictable.

Enter CSPRNG

crypto.randomBytes() taps the OS entropy pool — CryptGenRandom on Windows, /dev/urandom on Linux. Output is truly unpredictable and impossible to reconstruct.

const BUF_SIZE = 4096;
let buf = crypto.randomBytes(BUF_SIZE);
let bufOffset = 0;

function cryptoRandom(): number {
  if (bufOffset + 8 > BUF_SIZE) {
    buf = crypto.randomBytes(BUF_SIZE);
    bufOffset = 0;
  }
  const hi = buf.readUInt32BE(bufOffset);
  const lo = buf.readUInt32BE(bufOffset + 4);
  bufOffset += 8;
  return (((hi >>> 5) * 0x4000000 + (lo >>> 6)) / 0x20000000000000);
}

Human-Matched Distributions

CSPRNG alone isn't enough — you need distributions that match real human behavior. I use three distributions mixed by probability:

  • 70% Triangular (peaked at 30% of range) — fast clicks and quick typing
  • 25% Gaussian (bell curve) — normal navigation and reading
  • 5% Exponential (long tail) — occasional long thinking pauses

The Results

After implementing CSPRNG with human-matched distributions, the Crown Bot has been running 22 accounts for 3 months with zero detection. The visual test page shows the keyboard and mouse behavior in real-time.

✦ TipThe combination of CSPRNG + human distributions + bezier mouse movement makes automation statistically indistinguishable from human behavior.