@anonympins/fingerprint 0.7.0 → 0.7.1

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +1 -1
  3. package/composer.json +8 -1
  4. package/package.json +1 -1
  5. package/public/fingerprint-wordpress.zip +0 -0
  6. package/src/js/build-client.js +8 -10
  7. package/src/js/fingerprint.builder.js +37 -38
  8. package/src/js/fingerprint.client.js +1531 -1463
  9. package/src/js/fingerprint.client.obfuscated.js +1 -0
  10. package/src/js/fingerprint.js +152 -10
  11. package/src/js/fingerprint.utils.js +213 -213
  12. package/src/js/library.js +340 -376
  13. package/src/js/mongodb-store.js +1 -1
  14. package/src/js/optimization.worker.js +27 -27
  15. package/src/js/pow.solver.inline.js +154 -56
  16. package/src/js/pow.solver.js +180 -92
  17. package/src/js/pow.worker.js +48 -48
  18. package/src/js/redis-store.js +1 -1
  19. package/src/js/tests/fingerprint.client.init.test.js +146 -143
  20. package/src/js/tests/fingerprint.test.js +34 -7
  21. package/src/js/tests/ip-reputation.test.js +1 -0
  22. package/src/js/upow-model-task.js +14 -15
  23. package/src/php/AutoTuner.php +34 -34
  24. package/src/php/Challenge/ChallengeUtils.php +56 -10
  25. package/src/php/Config/SecurityProfiles.php +20 -0
  26. package/src/php/DirectFingerprint.php +190 -145
  27. package/src/php/FingerprintBuilder.php +29 -30
  28. package/src/php/FingerprintClient.php +147 -148
  29. package/src/php/FingerprintEngine.php +7 -5
  30. package/src/php/Ja3AnomalyDetector.php +33 -32
  31. package/src/php/Optimization/FunctionRegistry.php +7 -7
  32. package/src/php/Optimization/Optimization.php +24 -24
  33. package/src/php/Optimization/OptimizationOperators.php +26 -25
  34. package/src/php/Optimization/ProblemInitializers.php +52 -52
  35. package/src/php/ProblemManager.php +31 -34
  36. package/src/php/RequestContext.php +8 -1
  37. package/src/php/Store/IStore.php +7 -8
  38. package/src/php/Store/InMemoryStore.php +66 -66
  39. package/src/php/Store/MongoDbStore.php +5 -5
  40. package/src/php/Store/RedisStore.php +5 -5
  41. package/src/php/Store/StoreManager.php +35 -35
  42. package/src/php/Tests/ChallengeUtilsTest.php +453 -453
  43. package/src/php/Tests/DnsCircuitBreakerTest.php +105 -105
  44. package/src/php/Tests/FingerprintEngineTest.php +662 -662
  45. package/src/php/Tests/IpReputationTest.php +10 -0
  46. package/src/php/Tests/MaliciousPatternsTest.php +103 -103
  47. package/src/php/Tests/MetricsTest.php +97 -97
  48. package/src/php/Tests/ProblemManagerTest.php +376 -376
  49. package/src/php/Tests/QuicFingerprintTest.php +53 -53
  50. package/src/php/Tests/RequestUtilsTest.php +471 -471
  51. package/src/php/Tests/TLSClientHelloParserTest.php +177 -177
  52. package/src/php/Tests/config/ed25519_key.json +3 -3
  53. package/src/php/Utils/Env.php +49 -49
  54. package/src/php/Utils/MaliciousPatterns.php +74 -74
  55. package/src/php/Utils/MetricsManager.php +209 -209
  56. package/src/php/Utils/RequestUtils.php +129 -7
  57. package/src/php/Utils/TLSClientHelloParser.php +369 -369
  58. package/src/php/WordPress/WpDbStore.php +155 -0
  59. package/src/php/WordPress/fingerprint-wordpress.php +217 -0
  60. package/src/php/WordPress/package.php +123 -0
  61. package/src/php/bin/auto-tune.php +118 -118
package/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## Version 0.7.1
2
+
3
+ - 🔌 **Native WordPress Plugin Integration (`fingerprint-wordpress`)**:
4
+ - Full official WordPress plugin integration (`fingerprint-wordpress.php`) without external runtime dependencies, leveraging `$wpdb` through a dedicated `WpDbStore` adapter.
5
+ - Automatic SQL cache table provisioning and periodic cleanup of expired tickets via WP-Cron (`fingerprint_prune_expired_entries`).
6
+ - Automated packaging script (`package.php`) generating a ready-to-deploy ZIP archive (`fingerprint-wordpress.zip`).
7
+ - Cross-environment honeypot tripwires: immediately detects and drops automated scanners probing for non-WordPress entrypoints (Laravel, Symfony, Django, Spring Boot `/actuator`, phpMyAdmin, `.env`, `.git`).
8
+ - Admin dashboard security notice if running over unencrypted HTTP (warning about modern browsers disabling native `crypto.subtle` APIs in insecure contexts).
9
+ - 🔬 **JavaScript Prototype Tampering Detection (`detectTamperedPrototypes`)**:
10
+ - Added runtime integrity inspection on critical browser APIs (`HTMLCanvasElement.prototype.toDataURL`, `CanvasRenderingContext2D.prototype.getImageData`, `WebGLRenderingContext.prototype.getParameter`, and `window.fetch`).
11
+ - Accurately detects function hooks and proxies injected by evasion frameworks (Puppeteer Stealth, Frida, Selenium) and applies an aggressive penalty (`+80` to `behaviorScore`) via the `prototypeTampered` indicator.
12
+ - 📱 **Device Motion Variance Tracking (`motionVariance`)**:
13
+ - Analyzed accelerometer and gyroscope micro-variations via the `devicemotion` API.
14
+ - Distinguishes authentic handheld mobile devices from rack-mounted phone farms or automated rigs (detecting active touch interactions with zero natural sensor tremor, `motionVariance === 0`).
15
+ - 📝 **Code Standardization & Internationalization**:
16
+ - Harmonized and fully translated technical comments into English across optimization modules (`library.js`), PoW solvers, and build scripts.
17
+
1
18
  ## Version 0.7.0
2
19
 
3
20
  - 🛡️ **Targeted Re-Challenge Strategy (`mustReChallenge`)**: Re-introduced and hardened the re-challenge workflow specifically targeted at honeypot triggers and critical indicators (e.g., `honeypotScore >= mediumThreshold` or any indicator score reaching $\ge 100$). Legitimate sessions with valid clearance tickets are preserved, while active attack attempts immediately invalidate existing tickets and force verification.
package/README.md CHANGED
@@ -91,7 +91,7 @@ In your **pom.xml**, add :
91
91
  <dependency>
92
92
  <groupId>com.anonympins</groupId>
93
93
  <artifactId>fingerprint-engine</artifactId>
94
- <version>0.7.0</version>
94
+ <version>0.7.1</version>
95
95
  </dependency>
96
96
  ```
97
97
  ## Documentation
package/composer.json CHANGED
@@ -36,5 +36,12 @@
36
36
  "config": {
37
37
  "sort-packages": true
38
38
  },
39
- "minimum-stability": "stable"
39
+ "minimum-stability": "stable",
40
+ "scripts": {
41
+ "build:wordpress": "@php src/php/WordPress/package.php",
42
+ "package:wordpress": "@php src/php/WordPress/package.php"
43
+ },
44
+ "scripts-descriptions": {
45
+ "build:wordpress": "Empaquette et génère le fichier zip du plugin WordPress dans public/"
46
+ }
40
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anonympins/fingerprint",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
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",
Binary file
@@ -8,8 +8,8 @@ const __filename = fileURLToPath(import.meta.url);
8
8
  const __dirname = dirname(__filename);
9
9
 
10
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é).
11
+ * Attempts to run the build command for the WASM module.
12
+ * Does not fail the build if the command fails (e.g. em++ not found).
13
13
  */
14
14
  function buildWasm() {
15
15
  return new Promise((resolve) => {
@@ -22,7 +22,7 @@ function buildWasm() {
22
22
  } else {
23
23
  console.log('WASM module built successfully.');
24
24
  }
25
- resolve(); // Toujours résoudre la promesse pour ne pas bloquer le build principal.
25
+ resolve(); // Always resolve the promise so the main build is not blocked.
26
26
  });
27
27
  });
28
28
  }
@@ -36,14 +36,12 @@ async function buildClientScript() {
36
36
  console.log('Obfuscating client script...');
37
37
  const obfuscationResult = JavaScriptObfuscator.obfuscate(clientScriptContent, {
38
38
  compact: true,
39
- controlFlowFlattening: true, // Aplatit le flux de contrôle
40
- deadCodeInjection: true, // Injecte du code mort
39
+ controlFlowFlattening: true, // Flattens control flow
40
+ deadCodeInjection: true, // Injects dead code
41
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()
42
+ stringArrayRotate: true, // Rotates the string array
43
+ stringArrayShuffle: true, // Shuffles the string array
44
+ // Using a fixed seed yields deterministic obfuscation. For unique builds, use Math.random()
47
45
  seed: Math.random(),
48
46
  selfDefending: true,
49
47
  });
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Algorithme de hachage cyrb53 (rapide et faible taux de collision).
2
+ * cyrb53 hashing algorithm (fast with low collision rate).
3
3
  */
4
- // Exporté pour être utilisé comme fallback par fingerprint.client.js
4
+ // Exported for fallback usage by fingerprint.client.js
5
5
  export const cyrb53 = (str, seed = 0) => {
6
6
  const safeStr = (typeof str === 'string' ? str : String(str || '')).slice(0, 10000);
7
7
  let h1 = 0xdeadbeef ^ seed,
@@ -21,25 +21,25 @@ export const cyrb53 = (str, seed = 0) => {
21
21
  };
22
22
 
23
23
  /**
24
- * Classe pour construire une empreinte composite (Multi-Hash).
25
- * Format de sortie : "grp1:hash1|grp2:hash2|grp3:hash3"
24
+ * Class for constructing a composite fingerprint (Multi-Hash).
25
+ * Output format: "grp1:hash1|grp2:hash2|grp3:hash3"
26
26
  */
27
27
  export class FingerprintBuilder {
28
28
  constructor() {
29
- // Le hasher est maintenant une propriété pour pouvoir être surchargé par le client WASM.
29
+ // The hasher is an instance property so it can be overridden by the WASM client.
30
30
  this.components = new Map();
31
- // FIX: Initialiser le hasher par défaut à l'implémentation JS.
31
+ // Default hasher set to the JavaScript cyrb53 implementation.
32
32
  this.hasher = cyrb53;
33
33
  }
34
34
 
35
35
  /**
36
- * Ajoute un composant au hash global.
37
- * @param {string} group - Le nom du groupe (ex: 'hw', 'screen', 'geo')
38
- * @param {string|number|boolean} value - La valeur brute à hasher
36
+ * Adds a component to the global hash.
37
+ * @param {string} group - Component group identifier (e.g. 'hw', 'screen', 'geo').
38
+ * @param {string|number|boolean} value - Raw value to hash.
39
39
  */
40
40
  add(group, value) {
41
41
  if (value === undefined || value === null) return this;
42
- // On hash la valeur individuellement pour l'anonymiser et réduire sa taille
42
+ // Hash the value individually to anonymize and normalize length
43
43
  this.components.set(group, this.hasher(String(value)));
44
44
  return this;
45
45
  }
@@ -57,8 +57,8 @@ export class FingerprintBuilder {
57
57
  }
58
58
 
59
59
  /**
60
- * Affiche les composants actuels dans la console.
61
- * @param {string} [title='FingerprintBuilder Components'] - Un titre pour le log.
60
+ * Prints current components to the console.
61
+ * @param {string} [title='FingerprintBuilder Components'] - Title for output display.
62
62
  */
63
63
  log(title = 'FingerprintBuilder Components') {
64
64
  console.log(`--- ${title} ---`);
@@ -71,12 +71,12 @@ export class FingerprintBuilder {
71
71
  }
72
72
 
73
73
  /**
74
- * Génère la chaîne de signature finale.
75
- * Trie les clés pour garantir un ordre déterministe.
74
+ * Produces the final serialized signature string.
75
+ * Keys are sorted to guarantee deterministic serialization.
76
76
  */
77
77
  toString() {
78
78
  return Array.from(this.components.entries())
79
- .sort((a, b) => a[0].localeCompare(b[0])) // Tri alphabétique des clés
79
+ .sort((a, b) => a[0].localeCompare(b[0])) // Alphabetical key ordering
80
80
  .map(([key, hash]) => `${key}:${hash}`)
81
81
  .join("|");
82
82
  }
@@ -118,30 +118,29 @@ export class FingerprintBuilder {
118
118
  'x_forwarded_for', 'x_real_ip', 'cf_connecting_ip'
119
119
  ]);
120
120
 
121
- // Poids de "véracité" (Entropie/Stabilité)
122
- // Les poids sont augmentés pour donner plus d'importance aux signaux forts.
121
+ // Entropy / stability reliability weights
122
+ // Strongly invariant signals receive higher weighting
123
123
  const weights = {
124
- // --- Signaux très forts (difficiles à usurper) ---
125
- cvs: 5.0, // Canvas: Très haute entropie (Rendu unique du GPU/driver)
126
- gpu: 4.0, // GPU: Haute entropie (Matériel spécifique)
127
- ja3: 3.5, // JA3: Identifie la librairie TLS (très stable pour un client donné)
128
- ja4: 4.0, // JA4: Plus moderne, inclut HTTP/2
124
+ // --- High-entropy invariants (tamper-resistant) ---
125
+ cvs: 5.0, // Canvas: High entropy (GPU/driver rendering quirks)
126
+ gpu: 4.0, // GPU: High entropy (Physical graphics chipset)
127
+ ja3: 3.5, // JA3: TLS client stack fingerprint
128
+ ja4: 4.0, // JA4: Modern TLS fingerprint including HTTP/2
129
129
  h2: 3.0, // HTTP/2 settings frame fingerprint
130
130
  tcp: 2.5, // TCP/IP fingerprint
131
- ua: 2.0, // User-Agent: Signal fort, bien que modifiable
131
+ ua: 2.0, // User-Agent string
132
132
 
133
- // --- Signaux composites et dérivés ---
134
- client_fp_hash: 3.0, // Le hash de l'empreinte client est un signal très fort.
135
- browser: 1.5, // Le navigateur extrait du UA.
136
- os_version: 1.5, // L'OS extrait du UA.
137
- device_type: 1.0, // Le type d'appareil extrait du UA.
138
-
139
- // --- Signaux moyens ---
140
- hw: 1.5, // Hardware (CPU, RAM): Stabilité moyenne
141
- scr: 1.0, // Screen: Stabilité moyenne
142
- // 'os' est souvent la même chose que 'ch_platform', on peut le déprécier ou lui donner un poids faible.
143
- os: 0.8, // OS (nav.platform): Assez stable
144
- geo: 0.5, // Geo/Langue: Peut changer (VPN, voyage)
133
+ // --- Derived / composite signals ---
134
+ client_fp_hash: 3.0, // Client-side fingerprint hash
135
+ browser: 1.5, // Parsed browser family
136
+ os_version: 1.5, // Parsed OS family
137
+ device_type: 1.0, // Device form factor
138
+
139
+ // --- Medium-stability signals ---
140
+ hw: 1.5, // Hardware (cores, RAM): Moderate stability
141
+ scr: 1.0, // Screen geometry: Moderate stability
142
+ os: 0.8, // OS (nav.platform)
143
+ geo: 0.5, // Geo/locale: Subject to VPNs and travel
145
144
  };
146
145
 
147
146
  let weightedMatches = 0;
@@ -150,16 +149,16 @@ export class FingerprintBuilder {
150
149
  const allKeys = new Set([...map1.keys(), ...map2.keys()]);
151
150
 
152
151
  allKeys.forEach((key) => {
153
- // On ignore les clés volatiles pour cette comparaison spécifique.
152
+ // Ignore volatile keys during comparative evaluation
154
153
  if (volatileKeys.has(key)) {
155
154
  return;
156
155
  }
157
156
 
158
157
  const weight = weights[key] ?? 0;
159
- // On ne compte une clé dans le poids total que si elle est présente dans au moins une des deux empreintes.
158
+ // Only tally total weight if key is present in at least one fingerprint
160
159
  if (!map1.has(key) && !map2.has(key)) return;
161
160
 
162
- totalWeight += weight; // N'incrémenter que si la clé est pertinente.
161
+ totalWeight += weight;
163
162
  if (map1.get(key) === map2.get(key)) {
164
163
  weightedMatches += weight;
165
164
  }