mirror of
https://github.com/lukaszraczylo/mcp-captcharesolver.git
synced 2026-10-16 01:07:54 +00:00
feat(stealth): make evasion script coherent with generated fingerprint
- Convert assets/evasions.js to evasions.js.tmpl (Go text/template) - Placeholders: WebGLVendor, WebGLRenderer, Platform, Languages - Add navigator.platform spoof from fingerprint - ScriptParams gains OS, Browser, Locale, Seed fields (fieldalignment ordered) - ScriptResult gains Fingerprint field — returns the identity the script was rendered for - StealthScript calls GenerateFingerprint and renders template; single call gives both script and coherent fingerprint - languagesJS: locale to JS list (en-GB -> 'en-GB', 'en') - Template parsed once at init via template.Must - StealthScriptIn in tools.go gains OS, Browser, Locale, Seed pass-through - Tests: added TestStealthScriptCoherence asserting rendered values match fingerprint
This commit is contained in:
@@ -19,3 +19,30 @@ func TestStealthScript(t *testing.T) {
|
||||
t.Fatalf("missing apply metadata: %+v", res)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStealthScriptCoherence(t *testing.T) {
|
||||
p := ScriptParams{OS: "macos", Locale: "en-GB", Seed: 7}
|
||||
res := StealthScript(p)
|
||||
|
||||
// Independently generate the same fingerprint.
|
||||
fp := GenerateFingerprint(FingerprintParams{OS: "macos", Locale: "en-GB", Seed: 7})
|
||||
|
||||
// Script must contain the fingerprint's WebGL and platform values.
|
||||
for _, want := range []string{fp.WebGLVendor, fp.WebGLRenderer, fp.Platform} {
|
||||
if !strings.Contains(res.Script, want) {
|
||||
t.Errorf("script missing %q", want)
|
||||
}
|
||||
}
|
||||
// Script must contain navigator.platform spoof.
|
||||
if !strings.Contains(res.Script, "navigator.platform") {
|
||||
t.Error("script missing navigator.platform spoof")
|
||||
}
|
||||
// ScriptResult.Fingerprint must equal independently generated fingerprint.
|
||||
if res.Fingerprint != fp {
|
||||
t.Errorf("fingerprint mismatch:\n got %+v\n want %+v", res.Fingerprint, fp)
|
||||
}
|
||||
// Template must not produce empty script.
|
||||
if res.Script == "" {
|
||||
t.Fatal("empty rendered script")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user