@anonympins/fingerprint 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,34 @@
1
+ ## Version 0.5.2
2
+
3
+ - Security updates (CodeQL issues fixed)
4
+ - **Full options documentation** updated
5
+ - Bing / Google / Yandex bots automatically detected and ignored by `default_whitelist()`
6
+ - **Merkle Tree-Based Memory PoW Verification**: Integrated Merkle tree structures into the memory PoW challenge. By forcing the client to construct a Merkle tree and submit cryptographic proofs (*Merkle Proofs*) for randomly sampled memory blocks, the server can verify the challenge in $O(\log N)$ time and near-zero memory footprint. This mitigates critical server-side memory exhaustion and CPU DoS vulnerabilities, making high-difficulty memory-hard challenges safe for production.
7
+ - **Asynchronous CPU Bottleneck Avoidance (Web Workers)**: Offloaded CPU-intensive Proof-of-Work hashing loops to background Web Workers to prevent main-thread freezing and ensure smooth UI interactions. Includes a seamless, progressive fallback to main-thread execution using scheduler yielding (`scheduler.yield()`) or `setTimeout` timeouts when Web Workers are blocked by strict Content Security Policies (CSP).
8
+ - **WebGL1 & Legacy Context Fallback**: Added a comprehensive WebGL1 and legacy `experimental-webgl` context fallback to the GPU PoW solver and graphic fingerprint collector, ensuring full hardware-accelerated challenge compatibility for older browsers, legacy devices, and virtual machines lacking WebGPU or WebGL2 support.
9
+
10
+ ## Version 0.5.1
11
+
12
+ ### ✨ New Features
13
+
14
+ - **GPU Proof-of-Work (PoW) Challenge**: Introduced a highly parallelized chaotic logistic map float computation challenge utilizing WebGPU (with a fallback to WebGL2). This challenge is specifically designed to exhaust CPU-based headless emulators (such as SwiftShader). It includes sample-based server-side verification to prevent DoS vectors.
15
+ - **Biometric Keystroke Dynamics (Dwell & Flight Times)**: Introduced advanced behavioral biometric tracking by measuring key press duration (*dwell time*) and key-to-key transition intervals (*flight time*) to build a unique digraph/trigraph motor profile for the user.
16
+ - *Why it's a Killer Feature*: Automated text-injecting bots often simulate simple randomized delays between characters, but they fail to replicate natural human muscle memory patterns (such as ultra-fast cognitive transitions between adjacent keys on physical or virtual layouts). Server-side statistical checks (utilizing standard deviation, variance thresholds, and Benford's Law) immediately flag these robotic, uniform input patterns.
17
+ - **Stealthy Honeypot Traps (Shadow DOM)**: Implemented a new honeypot mechanism that conceals trap links and form fields within a closed Shadow DOM, with dynamic rendering styles calculated by nested CSS variables. This makes them invisible to legitimate users and standard browser automation tools, but highly detectable by bots that inject specific JS or use complex selectors, significantly increasing their behavioral signature.
18
+ - **Hot-Reloadable Security Configuration**: Enabled dynamic, in-memory updates of security configurations (weights, thresholds, patterns) without requiring a server restart. This ensures continuous adaptability to evolving threats (e.g., DDoS L7, scraping campaigns) without service interruption or latency.
19
+
20
+ ### 🚀 Improvements
21
+
22
+ - **Display & Protocol Anomaly Scoring**: Fully integrated `renderingAnomalyScore` and `quicAnomalyScore` across all backend engines (Node.js, PHP, Python). This enables real-time detection of virtual software framebuffers (like `Xvfb`) lacking physical V-Sync through jitter analysis, as well as HTTP/3 stream setting inconsistencies.
23
+ - **Security Profile Tuning**: Integrated display and QUIC anomaly detectors into the default security profiles (`balanced`, `strict`, `blog`, `ecommerce`) with custom weights.
24
+ - **Layout-Agnostic Client Tracking**: Enhanced the keystroke dynamics tracker to prioritize physical key locations (`KeyboardEvent.code`) over localized characters (`KeyboardEvent.key`), ensuring robust detection across different keyboard layouts (QWERTY, AZERTY) and virtual mobile keyboards.
25
+
26
+ ### 🐛 Bug Fixes
27
+
28
+ - **Node.js 24 Test Suite Compatibility**: Fixed unit test suite execution and environment configuration issues specifically encountered on Node.js 24.
29
+
30
+ ---
31
+
1
32
  ## Version 0.5.0
2
33
 
3
34
  ### ✨ New Features
package/README.md CHANGED
@@ -1,116 +1,119 @@
1
- # Fingerprint anti-bot protection
2
-
3
- NodeJS tests : [![https://github.com/anonympins/fingerprint/actions/workflows/ci-nodejs.yml](https://img.shields.io/github/actions/workflow/status/anonympins/fingerprint/ci-nodejs.yml)](https://github.com/anonympins/fingerprint/actions/workflows/ci-nodejs.yml) / PHP tests : [![https://github.com/anonympins/fingerprint/actions/workflows/ci-php.yml](https://img.shields.io/github/actions/workflow/status/anonympins/fingerprint/ci-php.yml)](https://github.com/anonympins/fingerprint/actions/workflows/ci-php.yml) / Python tests : [![https://github.com/anonympins/fingerprint/actions/workflows/ci-python.yml](https://img.shields.io/github/actions/workflow/status/anonympins/fingerprint/ci-php.yml)](https://github.com/anonympins/fingerprint/actions/workflows/ci-python.yml)
4
-
5
- [![https://github.com/anonympins/fingerprint/releases/tag/fingerprint-0.5.0](https://img.shields.io/github/v/release/anonympins/fingerprint)](https://github.com/anonympins/fingerprint/releases)
6
- [![https://raw.githubusercontent.com/anonympins/fingerprint/refs/heads/main/LICENSE](https://img.shields.io/github/license/anonympins/fingerprint)](https://github.com/anonympins/fingerprint/blob/main/LICENSE)
7
- [![https://github.com/anonympins/fingerprint/commits/main](https://img.shields.io/github/commit-activity/w/anonympins/fingerprint)](https://github.com/anonympins/fingerprint/commits/main)
8
- [![https://github.com/anonympins/fingerprint](https://img.shields.io/github/repo-size/anonympins/fingerprint)](https://github.com/anonympins/fingerprint)
9
-
10
- A multi-layered behavioral, cryptographic, and network analysis production-grade engine designed to identify and mitigate malicious requests (bots, scrapers, session hijacking, bot farms) in real-time. Supports **Node.js**, **Python** and **PHP** environments.
11
-
12
- It leverages multi-layer hardware fingerprinting, real-time behavioral analysis, passive network/TLS tracking, and adaptive/useful proof-of-work challenges to dynamically detect and mitigate scraping, scalping, account takeover (ATO), and sophisticated automated threats.
13
-
14
- Supported officially on **Node.js (>=20.0.0)**, **PHP (>=8.0)**, and **Python (>=3.8)**.
15
-
16
- ![illustration](https://i.ibb.co/fV1QT6Mf/image-c6e10859baae53bb595112ec08fc9e27.png)
17
-
18
- ### Presentation video
19
-
20
- [![Presentation](https://i.ibb.co/1tkPS01C/Capture-d-cran-2026-09-07-194728.png)](https://www.youtube.com/watch?v=Ujeznl0JAl4)
21
-
22
-
23
- ## 🚀 Key Features
24
-
25
- ### 1. 🧬 Polymorphic Client-Side WASM & JS Solvers
26
- * **Polymorphic WebAssembly Solver**: Dynamically generates unique, randomized C++ compiled WebAssembly binary modules per session. Prevents static analysis, bot automation, and emulator tampering.
27
- * **IndexedDB WASM Caching**: Transparently caches compiled WASM modules (`wasm-cache-db`) in the browser's IndexedDB, minimizing initialization overhead and execution lag on subsequent visits.
28
- * **Advanced Obfuscation**: Uses multi-layered control flow flattening and string array obfuscation for client-side libraries.
29
-
30
- ### 2. 💱 Useful Proof-of-Work (uPoW) & PoSpace
31
- * **Collaborative Useful PoW**: Instead of burning CPU cycles on arbitrary mathematical hash puzzles, suspicious clients solve complex optimization problems (e.g., *Traveling Salesperson*, *Portfolio Allocation*, *Facility Location*, *Fraud Detection Parameter Tuning*).
32
- * **Proof-of-Space (PoSpace) Challenge**: Forces browser clients to allocate and verify access to massive, persistent storage chunks (e.g., 100MB) inside IndexedDB, multiplying the cost of multi-threaded headless automation.
33
- * **Chained CPU/Memory Challenges**: Employs client-side resource exhaustion techniques (Chained SHA-256 target seeking & Memory Hard allocation vectors up to 128MB) that are validated in $O(1)$ on the server.
34
-
35
- ### 3. 🌐 Passive TLS, HTTP/2, and TCP/IP (p0f) Tracking
36
- * **Native JA3/JA4 TLS Handshake Parsing**: Inspects raw TLS client hello bytes to extract and analyze cipher suite arrangements, extensions, and elliptic curve formats.
37
- * **Passive TCP/IP Stack Fingerprinting**: Emulates `p0f` rules by analyzing raw TCP SYN packets (TTL, Window Size, MSS, WS, SACK) to classify client OS and detect raw network spoofing.
38
- * **Multi-Language Handshake Parser**: Built-in support for event-driven PHP runtimes (Swoole, ReactPHP, Workerman), Node.js native sockets, and Python ASGI/WSGI contexts.
39
-
40
- ### 4. 🧠 Stateful Behavioral Entropy & Click Variance
41
- * **Click Coordinate Variance**: Tracks exact click relative positions on DOM elements to compute spatial entropy, flagging bots clicking targets with robotic, mathematically perfect precision (zero variance).
42
- * **Mobile Touch Move Dynamics**: Captures mobile-specific touchscreen signals, analyzing tactile contact area radius, variable pressure indices, and multi-touch capabilities.
43
- * **Typing Keystroke Latency**: Measures real-time keystroke interval latencies to prevent automated text insertion.
44
-
45
- ### 5. 🔍 Cross-Layer & Analog Inconsistency Scoring
46
- * **Layer Cross-Referencing**: Analyzes inconsistencies between User-Agent declarations, Client-Hints (`Sec-CH-UA`), TLS Handshake capabilities, and TCP stacks (e.g., claiming Windows NT on Chrome but negotiating TLS like curl/Safari on a Linux kernel).
47
- * **Viewport Aspect ratio & Screen mismatches**: Detects virtualized viewports exceeding physical dimensions or fake hardware specifications.
48
-
49
- ### 6. 🦠 Honeypot Traps & Extensible WAF
50
- * **Signed Trap URLs**: Injects visually hidden, signed trap URLs into the DOM. Attempts to crawl, probe, or scrape these URLs immediately condemn the device.
51
- * **Recursive Injection Filters**: Inspects deeply nested payload structures (JSON/NoSQL/GraphQL) using a robust regular expression matrix to flag SQLi, XSS, XXE, SSTI, and JNDI (Log4Shell) vulnerabilities.
52
- * **ModSecurity NodeJS Extensibility**: Allows plugging in native core rule sets or custom WAF rule compilers into the honeypot pipeline.
53
-
54
- ### 🧬 Progressive Threshold Auto-Tuning
55
- * **Genetic Policy Optimizer**: Dynamically updates classification parameters using a multi-objective genetic algorithm on your actual sanitized traffic data.
56
- * **Inertial Parameter Sliding**: Adjusts security thresholds slowly with an adaptive learning rate to prevent configuration spikes.
57
- * **Sybil Protection**: Filters out traffic logs, ensuring individual compromised bot networks cannot pollute optimization datasets.
58
-
59
- ## Quick Start
60
-
61
- ### Node.js
62
-
63
- ```bash
64
- npm install @anonympins/fingerprint
65
- ```
66
-
67
- ### PHP
68
-
69
- ```bash
70
- composer require anonympins/fingerprint
71
- ```
72
-
73
- ### Python
74
- ```bash
75
- pip install fingerprint-engine
76
- ```
77
-
78
- ## Documentation
79
-
80
- To prevent documentation drift, all detailed guides and reference materials are maintained in the `doc/` directory. Please refer to [these resources](https://github.com/anonympins/fingerprint/wiki/home) to configure and integrate the engine:
81
-
82
- 1. **[Key Concepts & Suspicion Vectors](https://github.com/anonympins/fingerprint/wiki/concepts)**: Learn how the engine calculates suspicion scores across the 15 distinct vectors and manages the Proof-of-Work mitigation layers.
83
- 2. **[Node.js Integration Guide](https://github.com/anonympins/fingerprint/wiki/nodejs_integration)**: Step-by-step instructions for Express.js middleware and raw HTTP server integrations.
84
- 3. **[PHP Integration Guide](https://github.com/anonympins/fingerprint/wiki/php_integration)**: Configuration details for direct PHP integration, TLS fingerprinting forwarding via Nginx/Apache, and securing Prometheus metrics.
85
- 3. **[Python Integration Guide](https://github.com/anonympins/fingerprint/wiki/python_integration)**: Python middleware for ASGI and WSGI integration.
86
- 4. **[Full Configuration Options](https://github.com/anonympins/fingerprint/wiki/full_options)**: Complete parameter list for fine-tuning weights, custom honeypots, and security profile overrides.
87
- 5. **[API Reference](https://github.com/anonympins/fingerprint/wiki/api_reference)**: Public API signatures and guides on substituting the in-memory datastore with Redis or MongoDB.
88
-
89
- Start with the **[Documentation Portal](https://github.com/anonympins/fingerprint/wiki/home)** for a complete index.
90
-
91
- ## Contributing
92
-
93
- We welcome community contributions! Please read our **[Contributing Guidelines](https://github.com/anonympins/fingerprint/blob/main/CONTRIBUTING.md)** for information on:
94
- - Setting up your local environment (Node.js and PHP).
95
- - Running the test suites (`Vitest` and `PHPUnit`).
96
- - Coding and pull request standards.
97
-
98
- Thanks to our contributors :
99
- - [anonympins](https://github.com/anonympins)
100
-
101
- ## 💖 Sponsor This Project
102
-
103
- If this security suite helps protect your business against botnets, automated scraping, credential stuffing, or Layer 7 DDoS attacks, please consider supporting its active development!
104
-
105
- Sponsorship helps maintain the library, fund active updates, and keep the dynamic WebAssembly engine cutting-edge.
106
-
107
- ### 🌟 Featured Sponsors
108
-
109
- <img src="https://s6.imgcdn.dev/YJTWv9.png" width="100" alt="YJTWv9.png" border="0" valign="middle">
110
-
111
- [https://primals.net](https://primals.net) and sub-sites
112
-
113
-
114
- ## License
115
-
1
+ # Fingerprint anti-bot protection
2
+
3
+ NodeJS tests : [![https://github.com/anonympins/fingerprint/actions/workflows/ci-nodejs.yml](https://img.shields.io/github/actions/workflow/status/anonympins/fingerprint/ci-nodejs.yml)](https://github.com/anonympins/fingerprint/actions/workflows/ci-nodejs.yml) / PHP tests : [![https://github.com/anonympins/fingerprint/actions/workflows/ci-php.yml](https://img.shields.io/github/actions/workflow/status/anonympins/fingerprint/ci-php.yml)](https://github.com/anonympins/fingerprint/actions/workflows/ci-php.yml) / Python tests : [![https://github.com/anonympins/fingerprint/actions/workflows/ci-python.yml](https://img.shields.io/github/actions/workflow/status/anonympins/fingerprint/ci-php.yml)](https://github.com/anonympins/fingerprint/actions/workflows/ci-python.yml)
4
+
5
+ [![https://github.com/anonympins/fingerprint/releases/tag/fingerprint-0.5.0](https://img.shields.io/github/v/release/anonympins/fingerprint)](https://github.com/anonympins/fingerprint/releases)
6
+ [![https://raw.githubusercontent.com/anonympins/fingerprint/refs/heads/main/LICENSE](https://img.shields.io/github/license/anonympins/fingerprint)](https://github.com/anonympins/fingerprint/blob/main/LICENSE)
7
+ [![https://github.com/anonympins/fingerprint/commits/main](https://img.shields.io/github/commit-activity/w/anonympins/fingerprint)](https://github.com/anonympins/fingerprint/commits/main)
8
+ [![https://github.com/anonympins/fingerprint](https://img.shields.io/github/repo-size/anonympins/fingerprint)](https://github.com/anonympins/fingerprint)
9
+
10
+ A multi-layered behavioral, cryptographic, and network analysis production-grade engine designed to identify and mitigate malicious requests (bots, scrapers, session hijacking, bot farms) in real-time. Supports **Node.js**, **Python** and **PHP** environments.
11
+
12
+ It leverages multi-layer hardware fingerprinting, real-time behavioral analysis, passive network/TLS tracking, and adaptive/useful proof-of-work challenges to dynamically detect and mitigate scraping, scalping, account takeover (ATO), and sophisticated automated threats.
13
+
14
+ Supported officially on **Node.js (>=20.0.0)**, **PHP (>=8.0)**, and **Python (>=3.8)**.
15
+
16
+ ![illustration](https://i.ibb.co/fV1QT6Mf/image-c6e10859baae53bb595112ec08fc9e27.png)
17
+
18
+ ### Presentation video
19
+
20
+ [![Presentation](https://i.ibb.co/1tkPS01C/Capture-d-cran-2026-09-07-194728.png)](https://www.youtube.com/watch?v=Ujeznl0JAl4)
21
+
22
+
23
+ ## 🚀 Key Features
24
+
25
+ ### 1. 🧬 Polymorphic Client-Side WASM & JS Solvers
26
+ * **Polymorphic WebAssembly Solver**: Dynamically generates unique, randomized C++ compiled WebAssembly binary modules per session. Prevents static analysis, bot automation, and emulator tampering.
27
+ * **IndexedDB WASM Caching**: Transparently caches compiled WASM modules (`wasm-cache-db`) in the browser's IndexedDB, minimizing initialization overhead and execution lag on subsequent visits.
28
+ * **Advanced Obfuscation**: Uses multi-layered control flow flattening and string array obfuscation for client-side libraries.
29
+ * **Zero-Knowledge Proofs (ZKP) (New in v0.5.0)**: Added cryptographically secure Schnorr ZKPs (`generateZkpProof` on client and `verifyZkpProof` on server) for device fingerprints, allowing zero-disclosure fingerprint validation and making session tickets completely tamper-proof.
30
+
31
+ ### 2. 💱 Useful Proof-of-Work (uPoW) & PoSpace
32
+ * **Collaborative Useful PoW**: Instead of burning CPU cycles on arbitrary mathematical hash puzzles, suspicious clients solve complex optimization problems (e.g., *Traveling Salesperson*, *Portfolio Allocation*, *Facility Location*, *Fraud Detection Parameter Tuning*).
33
+ * **Cooperative Proof-of-Space (Coop PoSpace) (New in v0.5.0)**: Introduced decentralized, cooperative Proof-of-Space challenge routing within local subnets. Highly suspicious clients must coordinate with neighboring subnet peers to fetch and aggregate cryptographic blocks, vastly increasing the cost and complexity for distributed botnets trying to cycle residential proxy IPs.
34
+ * **Chained CPU/Memory Challenges**: Employs client-side resource exhaustion techniques (Chained SHA-256 target seeking & Memory Hard allocation vectors up to 128MB) that are validated in $O(1)$ on the server.
35
+
36
+ ### 3. 🌐 Passive TLS, HTTP/2, and TCP/IP (p0f) Tracking
37
+ * **Native JA3/JA4 TLS Handshake Parsing**: Inspects raw TLS client hello bytes to extract and analyze cipher suite arrangements, extensions, and elliptic curve formats.
38
+ * **Passive TCP/IP Stack Fingerprinting**: Emulates `p0f` rules by analyzing raw TCP SYN packets (TTL, Window Size, MSS, WS, SACK) to classify client OS and detect raw network spoofing.
39
+ * **Multi-Language Handshake Parser**: Built-in support for event-driven PHP runtimes (Swoole, ReactPHP, Workerman), Node.js native sockets, and Python ASGI/WSGI contexts.
40
+
41
+ ### 4. 🧠 Stateful Behavioral Entropy & Click Variance
42
+ * **Click Coordinate Variance**: Tracks exact click relative positions on DOM elements to compute spatial entropy, flagging bots clicking targets with robotic, mathematically perfect precision (zero variance).
43
+ * **Mobile Touch Move Dynamics**: Captures mobile-specific touchscreen signals, analyzing tactile contact area radius, variable pressure indices, and multi-touch capabilities.
44
+ * **Typing Keystroke Latency**: Measures real-time keystroke interval latencies to prevent automated text insertion.
45
+
46
+ ### 5. 🔍 Cross-Layer & Analog Inconsistency Scoring
47
+ * **Layer Cross-Referencing**: Analyzes inconsistencies between User-Agent declarations, Client-Hints (`Sec-CH-UA`), TLS Handshake capabilities, and TCP stacks (e.g., claiming Windows NT on Chrome but negotiating TLS like curl/Safari on a Linux kernel).
48
+ * **Viewport Aspect ratio & Screen mismatches**: Detects virtualized viewports exceeding physical dimensions or fake hardware specifications.
49
+ * **Optional Ed25519 Asymmetric Keys (New in v0.5.0)**: Dynamic and optional Ed25519 asymmetric key binding with an automatic fallback to symmetric AES-256-CBC encryption for session tickets.
50
+
51
+ ### 6. 🦠 Honeypot Traps & Extensible WAF
52
+ * **Signed Trap URLs**: Injects visually hidden, signed trap URLs into the DOM. Attempts to crawl, probe, or scrape these URLs immediately condemn the device.
53
+ * **Recursive Injection Filters (Enhanced in v0.5.0)**: Upgraded the WAF and input validation subsystem to recursively inspect deeply nested NoSQL/SQL structures, significantly improving protection against complex MongoDB/SQL injection vectors.
54
+ * **ModSecurity NodeJS Extensibility**: Allows plugging in native core rule sets or custom WAF rule compilers into the honeypot pipeline.
55
+
56
+ ### 🧬 Progressive Threshold Auto-Tuning
57
+ * **Genetic Policy Optimizer**: Dynamically updates classification parameters using a multi-objective genetic algorithm on your actual sanitized traffic data.
58
+ * **Inertial Parameter Sliding**: Adjusts security thresholds slowly with an adaptive learning rate to prevent configuration spikes.
59
+ * **Sybil Protection**: Filters out traffic logs, ensuring individual compromised bot networks cannot pollute optimization datasets.
60
+ * **Traffic Data Pruning (New in v0.5.0)**: Introduces automated traffic data pruning (`pruneTrafficData`) with time-based and size-based limiters to avoid memory leaks during long-running auto-tuning sessions.
61
+
62
+ ## Quick Start
63
+
64
+ ### Node.js
65
+
66
+ ```bash
67
+ npm install @anonympins/fingerprint
68
+ ```
69
+
70
+ ### PHP
71
+
72
+ ```bash
73
+ composer require anonympins/fingerprint
74
+ ```
75
+
76
+ ### Python
77
+ ```bash
78
+ pip install fingerprint-engine
79
+ ```
80
+
81
+ ## Documentation
82
+
83
+ To prevent documentation drift, all detailed guides and reference materials are maintained in the `doc/` directory. Please refer to [these resources](https://github.com/anonympins/fingerprint/wiki/home) to configure and integrate the engine:
84
+
85
+ 1. **[Key Concepts & Suspicion Vectors](https://github.com/anonympins/fingerprint/wiki/concepts)**: Learn how the engine calculates suspicion scores across the 15 distinct vectors and manages the Proof-of-Work mitigation layers.
86
+ 2. **[Node.js Integration Guide](https://github.com/anonympins/fingerprint/wiki/nodejs_integration)**: Step-by-step instructions for Express.js middleware and raw HTTP server integrations.
87
+ 3. **[PHP Integration Guide](https://github.com/anonympins/fingerprint/wiki/php_integration)**: Configuration details for direct PHP integration, TLS fingerprinting forwarding via Nginx/Apache, and securing Prometheus metrics.
88
+ 3. **[Python Integration Guide](https://github.com/anonympins/fingerprint/wiki/python_integration)**: Python middleware for ASGI and WSGI integration.
89
+ 4. **[Full Configuration Options](https://github.com/anonympins/fingerprint/wiki/full_options)**: Complete parameter list for fine-tuning weights, custom honeypots, and security profile overrides.
90
+ 5. **[API Reference](https://github.com/anonympins/fingerprint/wiki/api_reference)**: Public API signatures and guides on substituting the in-memory datastore with Redis or MongoDB.
91
+
92
+ Start with the **[Documentation Portal](https://github.com/anonympins/fingerprint/wiki/home)** for a complete index.
93
+
94
+ ## Contributing
95
+
96
+ We welcome community contributions! Please read our **[Contributing Guidelines](https://github.com/anonympins/fingerprint/blob/main/CONTRIBUTING.md)** for information on:
97
+ - Setting up your local environment (Node.js and PHP).
98
+ - Running the test suites (`Vitest` and `PHPUnit`).
99
+ - Coding and pull request standards.
100
+
101
+ Thanks to our contributors :
102
+ - [anonympins](https://github.com/anonympins)
103
+
104
+ ## 💖 Sponsor This Project
105
+
106
+ If this security suite helps protect your business against botnets, automated scraping, credential stuffing, or Layer 7 DDoS attacks, please consider supporting its active development!
107
+
108
+ Sponsorship helps maintain the library, fund active updates, and keep the dynamic WebAssembly engine cutting-edge.
109
+
110
+ ### 🌟 Featured Sponsors
111
+
112
+ <img src="https://s6.imgcdn.dev/YJTWv9.png" width="100" alt="YJTWv9.png" border="0" valign="middle">
113
+
114
+ [https://primals.net](https://primals.net) and sub-sites
115
+
116
+
117
+ ## License
118
+
116
119
  This project is licensed under the MIT License.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anonympins/fingerprint",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Advanced anti-bot library for Node.js using multi-layer fingerprinting (JA3, client-side, headers), behavioral analysis, and adaptive Proof-of-Work (PoW) challenges to mitigate scraping, scalping, and automated threats.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -27,23 +27,62 @@ function encodeSLEB128(val) {
27
27
  return bytes;
28
28
  }
29
29
 
30
- function generatePolymorphicInstructions() {
31
- const ops = [0x6a, 0x6b, 0x6c, 0x73]; // add, sub, mul, xor
30
+ function getRandomNonTrivialOpcodes(tempLocal) {
32
31
  const insts = [];
33
- const count = 3 + Math.floor(Math.random() * 5); // 3 to 7 instructions
34
-
35
- // Initialize dummy local 4
36
- const initVal = Math.floor(Math.random() * 1000) - 500;
37
- insts.push(0x41, ...encodeSLEB128(initVal), 0x21, 0x04);
38
-
32
+ const ops = [
33
+ // local.get tempLocal, i32.const rand, rotl, local.set tempLocal
34
+ () => [0x20, tempLocal, 0x41, ...encodeSLEB128(Math.floor(Math.random() * 31) + 1), 0x77, 0x21, tempLocal],
35
+ // local.get tempLocal, i32.const rand, rotr, local.set tempLocal
36
+ () => [0x20, tempLocal, 0x41, ...encodeSLEB128(Math.floor(Math.random() * 31) + 1), 0x78, 0x21, tempLocal],
37
+ // local.get tempLocal, i32.const rand, xor, local.set tempLocal
38
+ () => [0x20, tempLocal, 0x41, ...encodeSLEB128(Math.floor(Math.random() * 10000)), 0x73, 0x21, tempLocal],
39
+ // local.get tempLocal, popcnt, i32.const rand, mul, local.set tempLocal
40
+ () => [0x20, tempLocal, 0x69, 0x41, ...encodeSLEB128(Math.floor(Math.random() * 1000) + 1), 0x6c, 0x21, tempLocal],
41
+ // local.get tempLocal, clz, local.get tempLocal, ctz, add, local.set tempLocal
42
+ () => [0x20, tempLocal, 0x67, 0x20, tempLocal, 0x68, 0x6a, 0x21, tempLocal]
43
+ ];
44
+ const count = 2 + Math.floor(Math.random() * 3);
39
45
  for (let i = 0; i < count; i++) {
40
46
  const op = ops[Math.floor(Math.random() * ops.length)];
41
- const randVal = Math.floor(Math.random() * 1000) - 500;
42
- insts.push(0x20, 0x04, 0x41, ...encodeSLEB128(randVal), op, 0x21, 0x04);
47
+ insts.push(...op());
43
48
  }
44
49
  return insts;
45
50
  }
46
51
 
52
+ function generatePolymorphicInstructions(stateLocal = 4, tempLocal = 5) {
53
+ const insts = [];
54
+
55
+ // Initialize tempLocal with a random value
56
+ const initVal = Math.floor(Math.random() * 1000) - 500;
57
+ insts.push(0x41, ...encodeSLEB128(initVal), 0x21, tempLocal);
58
+
59
+ // Initialize stateLocal to 0
60
+ insts.push(0x41, ...encodeSLEB128(0), 0x21, stateLocal);
61
+
62
+ // Loop & Block for state machine
63
+ insts.push(0x03, 0x40); // loop
64
+ insts.push(0x02, 0x40); // block
65
+
66
+ for (let state = 0; state < 3; state++) {
67
+ insts.push(0x20, stateLocal, 0x41, ...encodeSLEB128(state), 0x46); // state == expected
68
+ insts.push(0x04, 0x40); // if
69
+ insts.push(...getRandomNonTrivialOpcodes(tempLocal));
70
+ insts.push(0x41, ...encodeSLEB128(state + 1), 0x21, stateLocal); // transit to state + 1
71
+ insts.push(0x0c, ...encodeULEB128(2)); // br 2 (targets loop start)
72
+ insts.push(0x0b); // end if
73
+ }
74
+
75
+ // Fallthrough / Default break (targets block depth 0, which exits the loop)
76
+ insts.push(0x0c, ...encodeULEB128(0));
77
+
78
+ // end block
79
+ insts.push(0x0b);
80
+ // end loop
81
+ insts.push(0x0b);
82
+
83
+ return insts;
84
+ }
85
+
47
86
  export class DynamicWasmGenerator {
48
87
  /**
49
88
  * Generates a unique polymorphic WebAssembly module containing a custom hash function
@@ -54,11 +93,11 @@ export class DynamicWasmGenerator {
54
93
  static generate(constants) {
55
94
  const { seed, multiplier, adder } = constants;
56
95
 
57
- const preLoopPoly = generatePolymorphicInstructions();
58
- const midLoopPoly = generatePolymorphicInstructions();
96
+ const preLoopPoly = generatePolymorphicInstructions(4, 5);
97
+ const midLoopPoly = generatePolymorphicInstructions(4, 5);
59
98
 
60
99
  const inst = [
61
- 0x01, 0x05, 0x7f, // Locals: 1 entry of 5 locals of type i32
100
+ 0x01, 0x06, 0x7f, // Locals: 1 entry of 6 locals of type i32
62
101
  ...preLoopPoly,
63
102
  // h = seed
64
103
  0x41, ...encodeSLEB128(seed),