High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
implement comprehensive stealth features (P8 features 3-10)
bot2e7fece8defe
diff --git a/handlers.go b/handlers.goindex 1cba7aad..3257b0e8 100644--- a/handlers.go+++ b/handlers.go@@ -6,6 +6,7 @@ import ("encoding/json""fmt""log/slog"+ "math/rand""net/http""os""path/filepath"@@ -914,17 +915,17 @@ func (b *Bridge) handleStealthStatus(w http.ResponseWriter, r *http.Request) {"automation_controlled": true, // --disable-blink-features=AutomationControlled"webdriver_hidden": true, // Stealth script removes navigator.webdriver"chrome_headless_new": headless, // Using new headless mode if headless- "user_agent_override": false, // TODO: implement UA rotation+ "user_agent_override": true, // POST /fingerprint/rotate implemented"webgl_vendor_override": true, // Stealth script spoofs WebGL"plugins_spoofed": true, // Stealth script adds fake plugins- "languages_spoofed": false, // TODO: implement language rotation- "webrtc_leak_prevented": false, // TODO: implement WebRTC blocking- "timezone_spoofed": false, // TODO: implement timezone spoofing- "canvas_noise": false, // TODO: implement canvas fingerprint noise+ "languages_spoofed": true, // Fingerprint rotation includes language+ "webrtc_leak_prevented": true, // Stealth script blocks WebRTC+ "timezone_spoofed": true, // Stealth script spoofs timezone+ "canvas_noise": true, // Canvas fingerprint noise added"audio_noise": false, // TODO: implement audio fingerprint noise- "font_spoofing": false, // TODO: implement font metrics spoofing- "hardware_concurrency": false, // TODO: implement CPU core spoofing- "device_memory": false, // TODO: implement memory spoofing+ "font_spoofing": true, // Font metrics randomized+ "hardware_concurrency": true, // CPU cores randomized+ "device_memory": true, // Device memory randomized}// Check which Chrome flags are active@@ -1017,3 +1018,189 @@ func getStealthRecommendations(features map[string]bool) []string {return recommendations}++// ── POST /fingerprint/rotate ───────────────────────────────++type fingerprintRequest struct {+ TabID string `json:"tabId"`+ OS string `json:"os"` // "random", "windows", "mac", "linux"+ Browser string `json:"browser"` // "chrome", "firefox", "safari", "edge"+ Screen string `json:"screen"` // "random", "1920x1080", "1366x768", etc+ Language string `json:"language"` // "en-US", "es-ES", etc+ Timezone int `json:"timezone"` // offset in minutes from UTC+ WebGL bool `json:"webgl"` // enable WebGL spoofing+ Canvas bool `json:"canvas"` // enable canvas noise+ Fonts bool `json:"fonts"` // enable font spoofing+ Audio bool `json:"audio"` // enable audio fingerprint noise+}++func (b *Bridge) handleFingerprintRotate(w http.ResponseWriter, r *http.Request) {+ var req fingerprintRequest+ if err := json.NewDecoder(http.MaxBytesReader(w, r.Body, maxBodySize)).Decode(&req); err != nil {+ jsonErr(w, 400, fmt.Errorf("decode: %w", err))+ return+ }++ ctx, _, err := b.TabContext(req.TabID)+ if err != nil {+ jsonErr(w, 404, err)+ return+ }++ // Generate fingerprint based on request+ fp := generateFingerprint(req)++ // Inject fingerprint overrides+ script := fmt.Sprintf(`+(function() {+ // User agent override+ Object.defineProperty(navigator, 'userAgent', {+ get: () => %q+ });+ Object.defineProperty(navigator, 'platform', {+ get: () => %q+ });+ Object.defineProperty(navigator, 'vendor', {+ get: () => %q+ });++ // Screen resolution+ Object.defineProperty(screen, 'width', { get: () => %d });+ Object.defineProperty(screen, 'height', { get: () => %d });+ Object.defineProperty(screen, 'availWidth', { get: () => %d });+ Object.defineProperty(screen, 'availHeight', { get: () => %d });++ // Language+ Object.defineProperty(navigator, 'language', { get: () => %q });+ Object.defineProperty(navigator, 'languages', { get: () => [%q] });++ // Timezone+ Date.prototype.getTimezoneOffset = function() { return %d; };++ // Hardware+ Object.defineProperty(navigator, 'hardwareConcurrency', { get: () => %d });+ Object.defineProperty(navigator, 'deviceMemory', { get: () => %d });++ console.log('Fingerprint rotated successfully');+})();+ `, fp.UserAgent, fp.Platform, fp.Vendor,+ fp.ScreenWidth, fp.ScreenHeight, fp.ScreenWidth-20, fp.ScreenHeight-80,+ fp.Language, fp.Language, fp.TimezoneOffset,+ fp.CPUCores, fp.Memory)++ tCtx, tCancel := context.WithTimeout(ctx, 5*time.Second)+ defer tCancel()++ if err := chromedp.Run(tCtx, chromedp.Evaluate(script, nil)); err != nil {+ jsonErr(w, 500, fmt.Errorf("inject fingerprint: %w", err))+ return+ }++ jsonResp(w, 200, map[string]any{+ "fingerprint": fp,+ "status": "rotated",+ })+}++type fingerprint struct {+ UserAgent string `json:"userAgent"`+ Platform string `json:"platform"`+ Vendor string `json:"vendor"`+ ScreenWidth int `json:"screenWidth"`+ ScreenHeight int `json:"screenHeight"`+ Language string `json:"language"`+ TimezoneOffset int `json:"timezoneOffset"`+ CPUCores int `json:"cpuCores"`+ Memory int `json:"memory"`+}++func generateFingerprint(req fingerprintRequest) fingerprint {+ fp := fingerprint{}++ // OS and browser combinations+ osConfigs := map[string]map[string]fingerprint{+ "windows": {+ "chrome": {+ UserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",+ Platform: "Win32",+ Vendor: "Google Inc.",+ },+ "edge": {+ UserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0",+ Platform: "Win32",+ Vendor: "Google Inc.",+ },+ },+ "mac": {+ "chrome": {+ UserAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",+ Platform: "MacIntel",+ Vendor: "Google Inc.",+ },+ "safari": {+ UserAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15",+ Platform: "MacIntel",+ Vendor: "Apple Computer, Inc.",+ },+ },+ }++ // Select OS/browser+ os := req.OS+ if os == "random" {+ if rand.Float64() < 0.7 {+ os = "windows"+ } else {+ os = "mac"+ }+ }++ browser := req.Browser+ if browser == "" {+ browser = "chrome"+ }++ if osConfig, ok := osConfigs[os]; ok {+ if browserConfig, ok := osConfig[browser]; ok {+ fp.UserAgent = browserConfig.UserAgent+ fp.Platform = browserConfig.Platform+ fp.Vendor = browserConfig.Vendor+ }+ }++ // Screen resolution+ screens := [][]int{+ {1920, 1080}, {1366, 768}, {1536, 864}, {1440, 900},+ {1280, 720}, {1600, 900}, {2560, 1440},+ }+ if req.Screen == "random" {+ screen := screens[rand.Intn(len(screens))]+ fp.ScreenWidth = screen[0]+ fp.ScreenHeight = screen[1]+ } else if req.Screen != "" {+ _, _ = fmt.Sscanf(req.Screen, "%dx%d", &fp.ScreenWidth, &fp.ScreenHeight)+ } else {+ fp.ScreenWidth = 1920+ fp.ScreenHeight = 1080+ }++ // Language+ if req.Language != "" {+ fp.Language = req.Language+ } else {+ fp.Language = "en-US"+ }++ // Timezone+ if req.Timezone != 0 {+ fp.TimezoneOffset = req.Timezone+ } else {+ fp.TimezoneOffset = -300 // EST+ }++ // Hardware+ fp.CPUCores = 4 + rand.Intn(4)*2+ fp.Memory = 4 + rand.Intn(4)*2++ return fp+}diff --git a/main.go b/main.goindex 66c6c341..f42e24d6 100644--- a/main.go+++ b/main.go@@ -149,6 +149,7 @@ func main() {mux.HandleFunc("GET /cookies", bridge.handleGetCookies)mux.HandleFunc("POST /cookies", bridge.handleSetCookies)mux.HandleFunc("GET /stealth/status", bridge.handleStealthStatus)+ mux.HandleFunc("POST /fingerprint/rotate", bridge.handleFingerprintRotate)srv := &http.Server{Addr: ":" + port, Handler: loggingMiddleware(corsMiddleware(authMiddleware(mux)))}diff --git a/stealth.js b/stealth.jsindex 9800ead4..8f1b8af7 100644--- a/stealth.js+++ b/stealth.js@@ -96,3 +96,81 @@ EventTarget.prototype.addEventListener = function(type, listener, options) {}return originalAddEventListener.call(this, type, listener, options);};++// Canvas fingerprinting noise+const originalToDataURL = HTMLCanvasElement.prototype.toDataURL;+const originalToBlob = HTMLCanvasElement.prototype.toBlob;+const originalGetImageData = CanvasRenderingContext2D.prototype.getImageData;++HTMLCanvasElement.prototype.toDataURL = function(...args) {+ const context = this.getContext('2d');+ if (context) {+ const width = this.width;+ const height = this.height;+ const imageData = context.getImageData(0, 0, width, height);+ for (let i = 0; i < imageData.data.length; i += 4) {+ imageData.data[i] = Math.min(255, Math.max(0, imageData.data[i] + (Math.random() - 0.5) * 0.5));+ imageData.data[i+1] = Math.min(255, Math.max(0, imageData.data[i+1] + (Math.random() - 0.5) * 0.5));+ imageData.data[i+2] = Math.min(255, Math.max(0, imageData.data[i+2] + (Math.random() - 0.5) * 0.5));+ }+ context.putImageData(imageData, 0, 0);+ }+ return originalToDataURL.apply(this, args);+};++HTMLCanvasElement.prototype.toBlob = function(callback, ...args) {+ const dataURL = this.toDataURL();+ originalToBlob.call(this, callback, ...args);+};++CanvasRenderingContext2D.prototype.getImageData = function(...args) {+ const imageData = originalGetImageData.apply(this, args);+ for (let i = 0; i < imageData.data.length; i += 4) {+ imageData.data[i] = Math.min(255, Math.max(0, imageData.data[i] + (Math.random() - 0.5) * 0.3));+ imageData.data[i+1] = Math.min(255, Math.max(0, imageData.data[i+1] + (Math.random() - 0.5) * 0.3));+ imageData.data[i+2] = Math.min(255, Math.max(0, imageData.data[i+2] + (Math.random() - 0.5) * 0.3));+ }+ return imageData;+};++// Font fingerprinting protection+const originalMeasureText = CanvasRenderingContext2D.prototype.measureText;+CanvasRenderingContext2D.prototype.measureText = function(text) {+ const metrics = originalMeasureText.apply(this, arguments);+ const noise = 0.01 * Math.random();+ return {+ ...metrics,+ width: metrics.width * (1 + noise)+ };+};++// WebRTC IP leak prevention+if (window.RTCPeerConnection) {+ window.RTCPeerConnection = new Proxy(window.RTCPeerConnection, {+ construct: function(target, args) {+ const pc = new target(...args);+ pc.createDataChannel = new Proxy(pc.createDataChannel, {+ apply: function() { throw new Error('WebRTC blocked'); }+ });+ pc.createOffer = new Proxy(pc.createOffer, {+ apply: function() { throw new Error('WebRTC blocked'); }+ });+ return pc;+ }+ });+}++// Timezone spoofing+Object.defineProperty(Date.prototype, 'getTimezoneOffset', {+ value: function() { return -300; } // EST+});++// Hardware concurrency spoofing+Object.defineProperty(navigator, 'hardwareConcurrency', {+ get: () => 4 + Math.floor(Math.random() * 4)+});++// Device memory spoofing+Object.defineProperty(navigator, 'deviceMemory', {+ get: () => 4 + Math.floor(Math.random() * 4) * 2+});