Skip to content

komen205/rust-browser-fingerprinting-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🦀 Browser Fingerprinting with Rust + WebAssembly

A browser fingerprinting demo that collects various browser characteristics to generate a unique device fingerprint. Built with Rust compiled to WebAssembly for performance and security.

Rust WebAssembly

🔍 What is Browser Fingerprinting?

Browser fingerprinting is a technique that collects information about a web browser's configuration and capabilities to create a unique identifier. This project demonstrates how various browser attributes can be combined to create a surprisingly unique fingerprint.

📋 Collected Data Points

Category Data Points
Browser User Agent, Language, Platform, Cookies, Do Not Track
Hardware CPU Cores, Device Memory, Touch Points
Display Screen Resolution, Color Depth, Pixel Ratio
Timezone Timezone Name, UTC Offset
Storage LocalStorage, SessionStorage, IndexedDB
Canvas Canvas 2D Fingerprint (rendered graphics hash)
WebGL Vendor, Renderer, Version, Extensions
Plugins Browser Plugins and MIME Types

🚀 Quick Start

Prerequisites

Install wasm-pack:

cargo install wasm-pack

Build

# Build the WebAssembly module
wasm-pack build --target web

# Or use the build script
./build.sh

Run

You need to serve the files from a web server (required for ES modules):

# Using Python
python3 -m http.server 8080

# Or using Node.js (install serve globally first: npm install -g serve)
serve .

# Or use any other static file server

Then open http://localhost:8080/www in your browser.

📁 Project Structure

.
├── Cargo.toml          # Rust dependencies
├── src/
│   └── lib.rs          # Rust fingerprinting library
├── www/
│   ├── index.html      # Main HTML page
│   ├── style.css       # Cyberpunk-themed styles
│   └── index.js        # JavaScript to interact with WASM
├── pkg/                # Generated WASM package (after build)
└── README.md

🛠️ How It Works

  1. Rust Library (src/lib.rs): Contains all the fingerprinting logic. Collects browser information using web-sys bindings to JavaScript APIs.

  2. WebAssembly: The Rust code is compiled to WASM using wasm-pack, creating a portable binary that runs in any modern browser.

  3. Frontend: A modern, cyberpunk-themed UI that displays all collected fingerprint data and the final hash.

🔐 Privacy Note

This is a demonstration project for educational purposes. All fingerprinting is performed locally in your browser - no data is sent to any server.

Browser fingerprinting can be used for:

  • ✅ Fraud detection
  • ✅ Bot detection
  • ✅ Security research
  • ⚠️ User tracking (use responsibly)

📊 Fingerprint Hash

The final fingerprint hash is generated by combining all collected data points and hashing them with SHA-256. This creates a unique identifier that can be used to recognize the same browser configuration across sessions.

🧪 Development

# Build in development mode (faster compilation)
wasm-pack build --target web --dev

# Build for production (optimized)
wasm-pack build --target web --release

📚 Dependencies

Rust

  • wasm-bindgen - Rust/JS interop
  • web-sys - Web API bindings
  • js-sys - JavaScript API bindings
  • serde - Serialization
  • sha2 - SHA-256 hashing
  • hex - Hex encoding
  • rust_code_obfuscator - Compile-time string obfuscation
  • cryptify - Encryption primitives for obfuscation

🔒 Code Obfuscation

This project uses rust_code_obfuscator to encrypt sensitive string literals at compile-time. This makes reverse engineering the WASM binary more difficult by:

  • Encrypting API property names (like cookieEnabled, deviceMemory)
  • Obfuscating WebGL extension names
  • Hiding fingerprinting-related strings

The strings are decrypted at runtime, so functionality remains unchanged.

📝 License

MIT License - feel free to use this for learning and experimentation.

🙏 Acknowledgments

About

Example of fingerprinting the browser using Rust + Obfuscation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published