@anonympins/fingerprint 0.6.7 → 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.
- package/CHANGELOG.md +33 -0
- package/README.md +3 -7
- package/composer.json +8 -1
- package/package.json +1 -1
- package/public/fingerprint-wordpress.zip +0 -0
- package/public/fp.wasm +0 -0
- package/src/js/build-client.js +9 -11
- package/src/js/dynamic-wasm.js +7 -7
- package/src/js/fingerprint.builder.js +37 -38
- package/src/js/fingerprint.client.js +236 -152
- package/src/js/fingerprint.client.obfuscated.js +1 -1
- package/src/js/fingerprint.js +517 -101
- package/src/js/fingerprint.utils.js +213 -213
- package/src/js/library.js +355 -384
- package/src/js/mongodb-store.js +1 -1
- package/src/js/optimization.worker.js +27 -27
- package/src/js/pow.solver.inline.js +206 -62
- package/src/js/pow.solver.js +235 -101
- package/src/js/pow.worker.js +48 -26
- package/src/js/redis-store.js +1 -1
- package/src/js/tests/fingerprint.client.init.test.js +146 -143
- package/src/js/tests/fingerprint.test.js +101 -40
- package/src/js/tests/ip-reputation.test.js +1 -0
- package/src/js/upow-model-task.js +14 -15
- package/src/php/AutoTuner.php +34 -34
- package/src/php/Challenge/ChallengeUtils.php +204 -32
- package/src/php/Config/SecurityProfiles.php +21 -0
- package/src/php/DirectFingerprint.php +190 -145
- package/src/php/FingerprintBuilder.php +29 -30
- package/src/php/FingerprintClient.php +24 -25
- package/src/php/FingerprintEngine.php +1836 -1880
- package/src/php/Ja3AnomalyDetector.php +258 -227
- package/src/php/Optimization/FunctionRegistry.php +7 -7
- package/src/php/Optimization/Optimization.php +24 -24
- package/src/php/Optimization/OptimizationOperators.php +28 -27
- package/src/php/Optimization/ProblemInitializers.php +52 -52
- package/src/php/ProblemManager.php +31 -34
- package/src/php/RequestContext.php +8 -1
- package/src/php/Store/IStore.php +7 -8
- package/src/php/Store/InMemoryStore.php +66 -66
- package/src/php/Store/MongoDbStore.php +5 -5
- package/src/php/Store/RedisStore.php +5 -5
- package/src/php/Store/StoreManager.php +35 -35
- package/src/php/Tests/ChallengeUtilsTest.php +453 -453
- package/src/php/Tests/DnsCircuitBreakerTest.php +105 -105
- package/src/php/Tests/FingerprintEngineTest.php +662 -693
- package/src/php/Tests/IpReputationTest.php +10 -0
- package/src/php/Tests/MaliciousPatternsTest.php +103 -103
- package/src/php/Tests/MetricsTest.php +97 -97
- package/src/php/Tests/ProblemManagerTest.php +376 -376
- package/src/php/Tests/QuicFingerprintTest.php +53 -53
- package/src/php/Tests/RequestUtilsTest.php +471 -471
- package/src/php/Tests/TLSClientHelloParserTest.php +177 -177
- package/src/php/Tests/config/ed25519_key.json +3 -3
- package/src/php/Utils/Env.php +49 -49
- package/src/php/Utils/MaliciousPatterns.php +74 -74
- package/src/php/Utils/MetricsManager.php +209 -209
- package/src/php/Utils/RequestUtils.php +236 -19
- package/src/php/Utils/TLSClientHelloParser.php +369 -212
- package/src/php/WordPress/WpDbStore.php +155 -0
- package/src/php/WordPress/fingerprint-wordpress.php +217 -0
- package/src/php/WordPress/package.php +123 -0
- package/src/php/bin/auto-tune.php +118 -118
|
@@ -6,34 +6,33 @@ namespace Anonympins\Fingerprint;
|
|
|
6
6
|
use Anonympins\Fingerprint\Config\SecurityProfiles;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* FingerprintClient -
|
|
9
|
+
* FingerprintClient - PHP wrapper for the client-side fingerprinting library.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* de "honeypots" (pièges à bots) dans les formulaires.
|
|
11
|
+
* Handles script injection and generation of polymorphic honeypot fields
|
|
12
|
+
* inside HTML forms.
|
|
14
13
|
*/
|
|
15
14
|
class FingerprintClient
|
|
16
15
|
{
|
|
17
16
|
/**
|
|
18
|
-
* @var string
|
|
17
|
+
* @var string Path to client script asset.
|
|
19
18
|
*/
|
|
20
19
|
private string $clientScriptPath;
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
|
-
* @var array
|
|
22
|
+
* @var array Configuration payload passed to `initializeClient`.
|
|
24
23
|
*/
|
|
25
24
|
private array $clientConfig;
|
|
26
25
|
|
|
27
26
|
/**
|
|
28
|
-
* @var string|null
|
|
27
|
+
* @var string|null Cryptographic nonce for Content Security Policy (CSP).
|
|
29
28
|
*/
|
|
30
29
|
private ?string $nonce;
|
|
31
30
|
|
|
32
31
|
/**
|
|
33
|
-
*
|
|
32
|
+
* Constructor.
|
|
34
33
|
*
|
|
35
|
-
* @param string $clientScriptPath
|
|
36
|
-
* @param array $clientConfig
|
|
34
|
+
* @param string $clientScriptPath Web-accessible path to `fingerprint.client.js`.
|
|
35
|
+
* @param array $clientConfig Client initialization options.
|
|
37
36
|
*/
|
|
38
37
|
public function __construct(string $clientScriptPath, array $clientConfig = [])
|
|
39
38
|
{
|
|
@@ -48,15 +47,15 @@ class FingerprintClient
|
|
|
48
47
|
'handleChallenges' => true,
|
|
49
48
|
'probationaryTtl' => 30000, // 30 seconds
|
|
50
49
|
],
|
|
51
|
-
'wasm' => true, //
|
|
52
|
-
'wasmPath' => '/fp.js' //
|
|
50
|
+
'wasm' => true, // Attempt to load WASM module
|
|
51
|
+
'wasmPath' => '/fp.js' // Path to WASM loader script
|
|
53
52
|
];
|
|
54
53
|
|
|
55
|
-
//
|
|
54
|
+
// Deep merge configuration overrides
|
|
56
55
|
$this->clientConfig = SecurityProfiles::deepMerge($defaultConfig, $clientConfig);
|
|
57
56
|
|
|
58
57
|
try {
|
|
59
|
-
//
|
|
58
|
+
// Generate CSP nonce when possible
|
|
60
59
|
$this->nonce = bin2hex(random_bytes(16));
|
|
61
60
|
} catch (\Exception $e) {
|
|
62
61
|
$this->nonce = null;
|
|
@@ -64,20 +63,20 @@ class FingerprintClient
|
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
66
|
+
* Generates a hidden honeypot form field.
|
|
67
|
+
* Traps automated bots while remaining invisible to human users.
|
|
69
68
|
*
|
|
70
|
-
* @param string $fieldName
|
|
71
|
-
* @return string
|
|
69
|
+
* @param string $fieldName Field name (must match client honeypot registration).
|
|
70
|
+
* @return string Generated HTML markup.
|
|
72
71
|
*/
|
|
73
72
|
public function generateHoneypotField(string $fieldName): string
|
|
74
73
|
{
|
|
75
|
-
//
|
|
74
|
+
// Register field in client configuration for monitoring
|
|
76
75
|
if (!in_array($fieldName, $this->clientConfig['honeypots'])) {
|
|
77
76
|
$this->clientConfig['honeypots'][] = $fieldName;
|
|
78
77
|
}
|
|
79
78
|
|
|
80
|
-
//
|
|
79
|
+
// Polymorphic CSS styling to robustly obscure honeypots
|
|
81
80
|
$styleOptions = [
|
|
82
81
|
'position:absolute; left:-9999px; top:-9999px; transform:scale(0); opacity:0; pointer-events:none;',
|
|
83
82
|
'position:fixed; left:-8888px; top:-8888px; width:0; height:0; overflow:hidden; opacity:0; pointer-events:none;',
|
|
@@ -104,16 +103,16 @@ class FingerprintClient
|
|
|
104
103
|
}
|
|
105
104
|
|
|
106
105
|
/**
|
|
107
|
-
*
|
|
106
|
+
* Generates HTML script tags to embed the client library on a page.
|
|
108
107
|
*
|
|
109
|
-
* @return string
|
|
108
|
+
* @return string HTML <script> markup.
|
|
110
109
|
*/
|
|
111
110
|
public function getScriptTag(): string
|
|
112
111
|
{
|
|
113
112
|
$configJson = json_encode($this->clientConfig);
|
|
114
113
|
$nonceAttr = $this->nonce ? ' nonce="' . $this->nonce . '"' : '';
|
|
115
114
|
|
|
116
|
-
//
|
|
115
|
+
// Inline initialization script embedded in HTML
|
|
117
116
|
$initScript = <<<JS
|
|
118
117
|
document.addEventListener('DOMContentLoaded', function() {
|
|
119
118
|
const config = {$configJson};
|
|
@@ -133,13 +132,13 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
|
133
132
|
});
|
|
134
133
|
JS;
|
|
135
134
|
|
|
136
|
-
//
|
|
135
|
+
// Combine library loader script and inline initialization
|
|
137
136
|
return '<script src="' . htmlspecialchars($this->clientScriptPath) . '"' . $nonceAttr . '></script>'
|
|
138
137
|
. '<script' . $nonceAttr . '>' . $initScript . '</script>';
|
|
139
138
|
}
|
|
140
139
|
|
|
141
140
|
/**
|
|
142
|
-
*
|
|
141
|
+
* Returns the generated CSP nonce.
|
|
143
142
|
* @return string|null
|
|
144
143
|
*/
|
|
145
144
|
public function getNonce(): ?string
|