Skip to main content
Experimental Crate: mimic

seleniumbase-rs-mimic (library seleniumbase_rs_mimic, in crates/mimic of seleniumbase-rs-stealth) sends requests that look like a measured Chrome on the wire: the same TLS ClientHello, the same HTTP/2 start, and the same header names, order and values. It builds a wreq client from an ImpersonationProfile, carries a browser’s cookies on in plain HTTP (HttpSession), puts a real Chrome behind a loopback proxy that replays its requests with the measured handshake (MitmProxy), and moves one identity between the two (StealthSession). Every wire value comes from a measurement embedded in the codec: a browser or system that was not measured is refused, not approximated. Only Chrome 155 on macOS is measured today; see Limits. The guides are HttpSession, MITM proxy and StealthSession.

Depend on it#

Cargo.toml

Write seleniumbase-rs by its plain git URL, exactly as above, so Cargo resolves it to the commit the crate uses and types such as sb_cdp::Page match. The crate depends on seleniumbase-rs-codec and seleniumbase-rs-scrape, and on wreq (a pinned release candidate), btls and tokio-btls (BoringSSL), hyper, tokio, ring and tracing. Building BoringSSL needs cmake and a C compiler.

Features#

The crate declares no Cargo features. Its own tests turn on test-util of the core.

Module map#

ModuleWhat it holdsPage
clientImpersonationProfile (a measured browser as data, with known_gaps), impersonation_client (a wreq::ClientBuilder from a profile), CustomProfileBuilder (a JA3 or an Akamai string laid over the measured profile), WireProtocol, ImpersonateError.Wire formats
convertPlain functions from the codec’s specs to wreq and BoringSSL options: tls_options, http2_options, wreq_headers, and check_emittable (can this TLS spec be sent at all); ConvertError names what cannot be. The only module besides client that names wreq types.Wire formats
http_sessionHttpSession (from_page, from_identity, get, request (a builder sent with HttpRequest::send), fetch, assess, export_identity, sync_cookies_back, cookie_count, profile), HttpOptions and its limits (DEFAULT_TIMEOUT, DEFAULT_MAX_BODY_BYTES, MAX_REDIRECT_LIMIT, …), HttpRequest, HttpReply, HttpError, Method, and the judging types Attempt, Fetched, Rules, Verdict. Cookies, redirects, pacing and challenge detection are done by hand, as a browser does them.HttpSession
mitmMitmProxy (a loopback forward proxy that ends Chrome’s TLS and replays each request with the profile’s fingerprint), MitmOptions, MitmStats, MitmError. It requires a random proxy token, refuses what it cannot intercept, and never tunnels blind.MITM proxy
stealth_sessionStealthSession and StealthSessionBuilder: one StealthIdentity in HTTP mode or in a real Chrome behind the proxy, escalating on a challenge and demoting after a clearance; StealthFetch, StealthError.StealthSession
tls_serverEphemeralCa (an in-memory P-256 CA, one leaf per host, pinned by SPKI, never written to disk), CaOptions, Leaf, the acceptor, TlsServerError.MITM proxy
capture_h2The capture_h2 tool: serves a local HTTPS site, points the local Chrome at it, and records its HTTP/2 frames and header block (and an HTTP/1.1 pass) for a new measurement; CaptureH2Error.Examples

Re-exports at the root#

Root nameModule
impersonation_client, CustomProfileBuilder, ImpersonateError, ImpersonationProfile, WireProtocolclient
HttpError, HttpOptions, HttpReply, HttpRequest, HttpSession, Method, ReplyProtocolhttp_session
HttpAttempt, HttpFetched, HttpRules, HttpVerdict, ReplyHeadershttp_session’s Attempt, Fetched, Rules, Verdict and Headers, renamed so they do not read as something else at the root
MitmError, MitmOptions, MitmProxy, MitmStatsmitm
StealthError, StealthFetch, StealthSession, StealthSessionBuilderstealth_session
CaOptions, EphemeralCa, Leaf, TlsServerErrortls_server

Errors#

Each module has its own error type (ImpersonateError, HttpError, MitmError, StealthError, TlsServerError, CaptureH2Error), built with thiserror; each module’s rustdoc lists its variants. A browser or system with no measurement is refused with a NotMeasured error rather than sent with guessed values.

Guides#

The item-by-item pages for this crate are still being written. Until then, the HttpSession, MITM proxy and StealthSession guides, the runnable examples, and the crate’s rustdoc (cargo doc -p seleniumbase-rs-mimic --open in the stealth repository) cover it.