impersonate-rs 0.1.3

A Rust wrapper for curl-impersonate, providing browser fingerprinting capabilities.
docs.rs failed to build impersonate-rs-0.1.3
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: impersonate-rs-0.1.1

impersonate-rs

Crates.io Documentation License

A high-performance Rust wrapper for curl-impersonate. This crate provides a safe, ergonomic, and idiomatic Rust interface for performing HTTP requests that mimic specific browser TLS fingerprints (Chrome, Firefox, Safari, Edge) to bypass sophisticated anti-bot protections.

🚀 Features

  • Browser Impersonation: Built-in support for mimicking modern browsers (Chrome, Edge, Safari, Firefox).
  • Custom Fingerprinting: Low-level control over JA3 (TLS) and Akamai (HTTP/2) fingerprints.
  • High Level API: Ergonomic Client and RequestBuilder similar to reqwest.
  • Strongly Typed: Browser enum ensures valid profile selection.
  • Header Consistency: Automatically manages headers to match the impersonated browser.

📦 Installation

Add this to your Cargo.toml:

[dependencies]
impersonate-rs = "0.1.0"

System Requirements

This crate links against libcurl-impersonate. You must have the shared library installed on your system.

Linux (Debian/Ubuntu):

# Example for installing curl-impersonate-chrome
sudo apt install build-essential pkg-config cmake ninja-build curl autoconf automake libtool
# Follow build instructions from https://github.com/lexiforest/curl-impersonate

Development Mode: If you don't have the library installed yet, you can build with the mock feature to stub the FFI calls:

[dependencies]
impersonate-rs = { version = "0.1.0", features = ["mock"] }

⚡ Usage

Basic Browser Impersonation

use impersonate_rs::{Client, Browser, Result};

fn main() -> Result<()> {
    // Create a client that impersonates Chrome 124
    let client = Client::builder()
        .impersonate(Browser::Chrome124)
        .build();

    // Perform a GET request
    let response = client.get("https://tls.browserleaks.com/json").send()?;

    // Print the response body
    println!("Response: {}", response.text()?);
    
    Ok(())
}

Custom JA3/Akamai Fingerprints

For advanced users who need to rotate fingerprints dynamically or use custom signatures.

use impersonate_rs::{Client, Result};

fn main() -> Result<()> {
    let client = Client::builder()
        // Set a custom JA3 string (TLS fingerprint)
        .ja3("771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0")
        // Set a custom Akamai string (HTTP/2 fingerprint)
        .akamai("1:65536,2:0,3:1000,4:6291456,6:262144|15663105|0|m,a,s,p")
        .build();

    let response = client.get("https://example.com").send()?;
    println!("{}", response.status());
    
    Ok(())
}

🛠️ CLI Tool

This crate includes a CLI tool for quick testing and verification.

# Clone the repo
git clone https://github.com/ajsb85/impersonate-rs.git
cd impersonate-rs

# Run against a target
cargo run --bin impersonate -- https://tls.browserleaks.com/json --impersonate chrome124

🤝 Contributing

Contributions are welcome! Please check out the CONTRIBUTING.md guide.

  1. Fork it
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -am 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Create a new Pull Request

📄 License

This project is licensed under the MIT License.

⚠️ Disclaimer

This library is intended for testing, security research, and interoperability purposes. Users are responsible for ensuring their use of this software complies with all applicable laws and terms of service of the websites they access.