@anonympins/fingerprint 0.5.4 → 0.6.0
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 +16 -0
- package/README.md +7 -6
- package/package.json +1 -1
- package/src/js/build-client.js +67 -67
- package/src/js/fingerprint.client.js +1445 -1271
- package/src/js/fingerprint.client.obfuscated.js +1 -1
- package/src/js/fingerprint.js +499 -116
- package/src/js/obfuscation.worker.js +23 -0
- package/src/js/pow.solver.inline.js +37 -28
- package/src/js/pow.solver.js +37 -28
- package/src/js/problem-manager.js +22 -0
- package/src/js/tests/cross_parity.test.js +175 -0
- package/src/js/tests/fingerprint.client.test.js +130 -128
- package/src/js/tests/fingerprint.test.js +42 -2
- package/src/js/tests/obfuscation.test.js +48 -0
- package/src/js/ttl-optimization.worker.js +51 -0
- package/src/php/AutoTuner.php +42 -0
- package/src/php/Challenge/ChallengeUtils.php +57 -6
- package/src/php/FingerprintBuilder.php +193 -185
- package/src/php/FingerprintEngine.php +147 -1
- package/src/php/ProblemManager.php +20 -0
- package/src/php/Tests/ChallengeUtilsTest.php +446 -285
- package/src/php/Utils/RequestUtils.php +19 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## Version 0.6.0
|
|
2
|
+
|
|
3
|
+
- **🛡️ Cooperative Challenge Better Security**: Hardened cooperative Proof-of-Space and challenge routing mechanics within subnet peers, preventing rogue registrations and ensuring high-fidelity security validation on decentralized networks (Contributed by @anonympins).
|
|
4
|
+
- **⚡ Math Optimizations & TTL Worker**: Optimized performance for 64-bit integers and the `cyrb53` hashing implementation on PHP 7+, reducing CPU overhead. Integrated automated background TTL optimization worker execution (Contributed by @anonympins).
|
|
5
|
+
- **🧹 IP Pruning**: Standardized and optimized IP pruning and rate-limiting data lifecycles to prevent memory exhaustion and leaks during high-concurrency scraping attempts (Contributed by @anonympins).
|
|
6
|
+
- Java integration (see README and wiki)
|
|
7
|
+
|
|
8
|
+
## Version 0.5.5
|
|
9
|
+
|
|
10
|
+
- **🔒 Client Session Handshake & HMAC Metric Signing**: Implemented elliptic-curve Diffie-Hellman (ECDH over curve `P-256`) key exchange protocol during client initialization (`?fp_handshake=1`). Leveraged the negotiated session key to cryptographically sign behavioral metrics (`signMetrics`) on the client using HMAC-SHA256, protecting against replay attacks and telemetry tampering.
|
|
11
|
+
- **🧵 Non-Blocking Polymorphic Obfuscation Worker**: Offloaded CPU-heavy JavaScript obfuscation and parsing pipelines (`compilePolymorphicJs`) to a dedicated Node.js Worker Thread (`obfuscation.worker.js`). This isolates resource-intensive obfuscation tasks from the main event loop, preventing latency spikes on production servers.
|
|
12
|
+
- **💾 Performance Optimizations with SimpleLRUCache**: Added an in-memory `SimpleLRUCache` to eliminate synchronous file system calls (`readFileSync`). Standardized caching of custom HTML challenge pages and static files (`fp.js`/`fp.wasm`).
|
|
13
|
+
- **🛡️ Auto-Tuner Stability Guardrails & Rollbacks**: Implemented post-calculation validation checks with a configurable `validationTolerance` threshold (default `0.15`). Automatically rolls back unstable parameters and triggers an `autotuning_instability_alert` if proposed changes degrade FPR/FNR metrics.
|
|
14
|
+
- **🧬 Strict Multi-Language Cross-Parity**: Aligned 32-bit single-precision floating-point (IEEE 754) calculations for chaotic map trajectories across WebGPU, WebGL, C++ WASM, and PHP environments. Guaranteed bit-to-bit convergence across 1,000 random seeds.
|
|
15
|
+
- **🧮 Fixed Zero Threshold PoW Shift Error**: Patched a potential bitwise shift crash (`1n << shift` with a negative shift) inside `calculateTarget` when the suspicion score dropped to or below zero. Legitimate requests now resolve directly to the maximum target range.
|
|
16
|
+
|
|
1
17
|
## Version 0.5.4
|
|
2
18
|
|
|
3
19
|
- **🔒 JA3/JA4 Handshake Parsing Hardening (PHP/Python)**: Fixed ALPN length constraints and untangled nested loops in the binary TLS Client Hello decoder, ensuring native and highly reliable raw JA4 fingerprint calculations directly at the socket layer.
|
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# Fingerprint anti-bot protection
|
|
2
2
|
|
|
3
|
-
NodeJS tests : [](https://github.com/anonympins/fingerprint/actions/workflows/ci-nodejs.yml) / PHP tests : [](https://github.com/anonympins/fingerprint/actions/workflows/ci-php.yml) / Python tests : [](https://github.com/anonympins/fingerprint/actions/workflows/ci-nodejs.yml) / PHP tests : [](https://github.com/anonympins/fingerprint/actions/workflows/ci-php.yml) / Python tests : [](https://github.com/anonympins/fingerprint/actions/workflows/ci-python.yml) / Java tests : [](https://github.com/anonympins/fingerprint/actions/workflows/ci-java.yml)
|
|
4
4
|
|
|
5
5
|
[](https://github.com/anonympins/fingerprint/releases)
|
|
6
6
|
[](https://github.com/anonympins/fingerprint/blob/main/LICENSE)
|
|
7
7
|
[](https://github.com/anonympins/fingerprint/commits/main)
|
|
8
8
|
[](https://github.com/anonympins/fingerprint)
|
|
9
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.
|
|
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**, **Java**, **Python** and **PHP** environments.
|
|
11
11
|
|
|
12
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
13
|
|
|
14
|
-
Supported officially on **Node.js (>=20.0.0)**, **PHP (>=8.0)**, and **Python (>=3.8)**.
|
|
14
|
+
Supported officially on **Node.js (>=20.0.0)**, **PHP (>=8.0)**, Java (>=17), and **Python (>=3.8)**.
|
|
15
15
|
|
|
16
16
|

|
|
17
17
|
|
|
@@ -85,9 +85,10 @@ To prevent documentation drift, all detailed guides and reference materials are
|
|
|
85
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
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
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
4. **[Python Integration Guide](https://github.com/anonympins/fingerprint/wiki/python_integration)**: Python middleware for ASGI and WSGI integration.
|
|
89
|
+
5. **[Java Integration Guide](https://github.com/anonympins/fingerprint/wiki/java_integration)**: Java library (Servlet, Spring WebFlux)
|
|
90
|
+
6. **[Full Configuration Options](https://github.com/anonympins/fingerprint/wiki/full_options)**: Complete parameter list for fine-tuning weights, custom honeypots, and security profile overrides.
|
|
91
|
+
7. **[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
|
|
|
92
93
|
Start with the **[Documentation Portal](https://github.com/anonympins/fingerprint/wiki/home)** for a complete index.
|
|
93
94
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anonympins/fingerprint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
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",
|
package/src/js/build-client.js
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import {promises as fs} from 'node:fs';
|
|
2
|
-
import {dirname, join} from 'node:path';
|
|
3
|
-
import {fileURLToPath} from 'node:url';
|
|
4
|
-
import {exec} from 'node:child_process';
|
|
5
|
-
import JavaScriptObfuscator from 'javascript-obfuscator';
|
|
6
|
-
|
|
7
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
-
const __dirname = dirname(__filename);
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Tente d'exécuter la commande de build pour le module WASM.
|
|
12
|
-
* Ne bloque pas le build si la commande échoue (ex: em++ non trouvé).
|
|
13
|
-
*/
|
|
14
|
-
function buildWasm() {
|
|
15
|
-
return new Promise((resolve) => {
|
|
16
|
-
console.log('Attempting to build WASM module (optional)...');
|
|
17
|
-
const command = "em++ src/cpp/main.cpp src/cpp/utils.cpp -o public/fp.js -s WASM=1 -s MODULARIZE=1 -s EXPORT_NAME='createFingerprintModule' -s \"EXPORTED_FUNCTIONS=['_hash_string','_solve_cpu_target','_solve_memory_challenge']\" -O3 --no-entry";
|
|
18
|
-
|
|
19
|
-
exec(command, (error, stdout, stderr) => {
|
|
20
|
-
if (error) {
|
|
21
|
-
console.warn('WASM build failed (this is optional and can be ignored):', stderr);
|
|
22
|
-
} else {
|
|
23
|
-
console.log('WASM module built successfully.');
|
|
24
|
-
}
|
|
25
|
-
resolve(); // Toujours résoudre la promesse pour ne pas bloquer le build principal.
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async function buildClientScript() {
|
|
31
|
-
try {
|
|
32
|
-
console.log('Reading client script...');
|
|
33
|
-
const clientScriptPath = join(__dirname, 'fingerprint.client.js');
|
|
34
|
-
const clientScriptContent = await fs.readFile(clientScriptPath, 'utf-8');
|
|
35
|
-
|
|
36
|
-
console.log('Obfuscating client script...');
|
|
37
|
-
const obfuscationResult = JavaScriptObfuscator.obfuscate(clientScriptContent, {
|
|
38
|
-
compact: true,
|
|
39
|
-
controlFlowFlattening: true, // Aplatit le flux de contrôle
|
|
40
|
-
deadCodeInjection: true, // Injecte du code mort
|
|
41
|
-
stringArray: true,
|
|
42
|
-
stringArrayRotate: true, // Fait tourner le tableau de chaînes
|
|
43
|
-
stringArrayShuffle: true, // Mélange le tableau de chaînes
|
|
44
|
-
// L'utilisation d'une graine (seed) de 0 signifie que l'obfuscation sera déterministe
|
|
45
|
-
// pour une même entrée. Pour une obfuscation unique à chaque build, on peut utiliser
|
|
46
|
-
// une graine aléatoire, par exemple : seed: Math.random()
|
|
47
|
-
seed: Math.random(),
|
|
48
|
-
selfDefending: true,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const obfuscatedCode = obfuscationResult.getObfuscatedCode();
|
|
52
|
-
|
|
53
|
-
console.log('Writing obfuscated script to fingerprint.client.obfuscated.js...');
|
|
54
|
-
await fs.writeFile(join(__dirname, './fingerprint.client.obfuscated.js'), obfuscatedCode);
|
|
55
|
-
|
|
56
|
-
console.log('Client script build process completed successfully.');
|
|
57
|
-
} catch (error) {
|
|
58
|
-
console.error('Error during client script build:', error);
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async function main() {
|
|
64
|
-
await buildClientScript();
|
|
65
|
-
await buildWasm();
|
|
66
|
-
}
|
|
67
|
-
|
|
1
|
+
import {promises as fs} from 'node:fs';
|
|
2
|
+
import {dirname, join} from 'node:path';
|
|
3
|
+
import {fileURLToPath} from 'node:url';
|
|
4
|
+
import {exec} from 'node:child_process';
|
|
5
|
+
import JavaScriptObfuscator from 'javascript-obfuscator';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Tente d'exécuter la commande de build pour le module WASM.
|
|
12
|
+
* Ne bloque pas le build si la commande échoue (ex: em++ non trouvé).
|
|
13
|
+
*/
|
|
14
|
+
function buildWasm() {
|
|
15
|
+
return new Promise((resolve) => {
|
|
16
|
+
console.log('Attempting to build WASM module (optional)...');
|
|
17
|
+
const command = "em++ src/cpp/main.cpp src/cpp/utils.cpp -o public/fp.js -s WASM=1 -s MODULARIZE=1 -s EXPORT_NAME='createFingerprintModule' -s \"EXPORTED_FUNCTIONS=['_hash_string','_solve_cpu_target','_solve_memory_challenge','_generate_gpu_pow_trajectory']\" -O3 --no-entry";
|
|
18
|
+
|
|
19
|
+
exec(command, (error, stdout, stderr) => {
|
|
20
|
+
if (error) {
|
|
21
|
+
console.warn('WASM build failed (this is optional and can be ignored):', stderr);
|
|
22
|
+
} else {
|
|
23
|
+
console.log('WASM module built successfully.');
|
|
24
|
+
}
|
|
25
|
+
resolve(); // Toujours résoudre la promesse pour ne pas bloquer le build principal.
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function buildClientScript() {
|
|
31
|
+
try {
|
|
32
|
+
console.log('Reading client script...');
|
|
33
|
+
const clientScriptPath = join(__dirname, 'fingerprint.client.js');
|
|
34
|
+
const clientScriptContent = await fs.readFile(clientScriptPath, 'utf-8');
|
|
35
|
+
|
|
36
|
+
console.log('Obfuscating client script...');
|
|
37
|
+
const obfuscationResult = JavaScriptObfuscator.obfuscate(clientScriptContent, {
|
|
38
|
+
compact: true,
|
|
39
|
+
controlFlowFlattening: true, // Aplatit le flux de contrôle
|
|
40
|
+
deadCodeInjection: true, // Injecte du code mort
|
|
41
|
+
stringArray: true,
|
|
42
|
+
stringArrayRotate: true, // Fait tourner le tableau de chaînes
|
|
43
|
+
stringArrayShuffle: true, // Mélange le tableau de chaînes
|
|
44
|
+
// L'utilisation d'une graine (seed) de 0 signifie que l'obfuscation sera déterministe
|
|
45
|
+
// pour une même entrée. Pour une obfuscation unique à chaque build, on peut utiliser
|
|
46
|
+
// une graine aléatoire, par exemple : seed: Math.random()
|
|
47
|
+
seed: Math.random(),
|
|
48
|
+
selfDefending: true,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const obfuscatedCode = obfuscationResult.getObfuscatedCode();
|
|
52
|
+
|
|
53
|
+
console.log('Writing obfuscated script to fingerprint.client.obfuscated.js...');
|
|
54
|
+
await fs.writeFile(join(__dirname, './fingerprint.client.obfuscated.js'), obfuscatedCode);
|
|
55
|
+
|
|
56
|
+
console.log('Client script build process completed successfully.');
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error('Error during client script build:', error);
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function main() {
|
|
64
|
+
await buildClientScript();
|
|
65
|
+
await buildWasm();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
68
|
main();
|