Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix 8F-6 + 8F-2: configurable Chrome version, stable PRNG seed

botb22d3d5e126f
diff --git a/README.md b/README.md
index 2d0d30f4..c72b0fe1 100644
--- a/README.md
+++ b/README.md
@@ -137,6 +137,7 @@ All via environment variables:
| `BRIDGE_PROFILE` | `~/.pinchtab/chrome-profile` | Chrome profile directory |
| `BRIDGE_STATE_DIR` | `~/.pinchtab` | State/session storage |
| `BRIDGE_NO_RESTORE` | `false` | Skip restoring tabs from previous session |
+| `BRIDGE_CHROME_VERSION` | `133.0.6943.98` | Chrome version in User-Agent strings (keep current to avoid detection) |
| `CDP_URL` | *(none)* | Connect to existing Chrome instead of launching |
## Architecture
diff --git a/config.go b/config.go
index 7c98d421..f59a9142 100644
--- a/config.go
+++ b/config.go
@@ -52,6 +52,7 @@ var (
headless = os.Getenv("BRIDGE_HEADLESS") == "true"
noRestore = os.Getenv("BRIDGE_NO_RESTORE") == "true"
profileDir = envOr("BRIDGE_PROFILE", filepath.Join(homeDir(), ".pinchtab", "chrome-profile"))
+ chromeVersion = envOr("BRIDGE_CHROME_VERSION", "133.0.6943.98")
actionTimeout = 15 * time.Second
navigateTimeout = 30 * time.Second
shutdownTimeout = 10 * time.Second
diff --git a/handler_stealth.go b/handler_stealth.go
index 9fb39019..46422ada 100644
--- a/handler_stealth.go
+++ b/handler_stealth.go
@@ -274,19 +274,19 @@ func generateFingerprint(req fingerprintRequest) fingerprint {
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/131.0.0.0 Safari/537.36",
+ UserAgent: fmt.Sprintf("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36", chromeVersion),
Platform: "Win32",
Vendor: "Google Inc.",
},
"edge": {
- UserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0",
+ UserAgent: fmt.Sprintf("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36 Edg/%s", chromeVersion, chromeVersion),
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/131.0.0.0 Safari/537.36",
+ UserAgent: fmt.Sprintf("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36", chromeVersion),
Platform: "MacIntel",
Vendor: "Google Inc.",
},
diff --git a/main.go b/main.go
index f42e24d6..18d32570 100644
--- a/main.go
+++ b/main.go
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log/slog"
+ "math/rand"
"net/http"
"os"
"os/signal"
@@ -86,7 +87,7 @@ func main() {
chromedp.Flag("js-flags", "--random-seed=1157259157"),
// Identity - more realistic user agent with proper versioning
- chromedp.UserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"),
+ chromedp.UserAgent(fmt.Sprintf("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36", chromeVersion)),
chromedp.WindowSize(1366, 768), // More common resolution
}
@@ -104,10 +105,12 @@ func main() {
browserCtx, browserCancel := chromedp.NewContext(bridge.allocCtx)
defer browserCancel()
- // Inject stealth script (embedded from stealth.js)
+ // Inject stealth script with a session-stable seed (stays constant across page loads)
+ stealthSeed := rand.Intn(1000000000)
+ seededScript := fmt.Sprintf("var __pinchtab_seed = %d;\n", stealthSeed) + stealthScript
if err := chromedp.Run(browserCtx,
chromedp.ActionFunc(func(ctx context.Context) error {
- _, err := page.AddScriptToEvaluateOnNewDocument(stealthScript).Do(ctx)
+ _, err := page.AddScriptToEvaluateOnNewDocument(seededScript).Do(ctx)
return err
}),
); err != nil {
diff --git a/stealth.js b/stealth.js
index d4f50c7e..a080d0bf 100644
--- a/stealth.js
+++ b/stealth.js
@@ -1,13 +1,26 @@
// Enhanced stealth script injected into every new document via page.AddScriptToEvaluateOnNewDocument.
// Hides automation indicators from sophisticated bot detection systems like X.com.
-// Hardware values - seeded and consistent per session
-// MUST BE DEFINED FIRST before any usage
-const sessionSeed = Date.now() % 1000000;
-const seededRandom = (seed) => {
- const x = Math.sin(seed) * 10000;
- return x - Math.floor(x);
-};
+// Session-stable seed injected by Go at launch time via __pinchtab_seed.
+// Falls back to a fixed value if not set (shouldn't happen in normal operation).
+// This seed is constant across all page loads within the same Pinchtab session,
+// so hardware fingerprint values stay consistent (as they would in a real browser).
+const sessionSeed = (typeof __pinchtab_seed !== 'undefined') ? __pinchtab_seed : 42;
+
+// Mulberry32 PRNG — simple, fast, uniform distribution, deterministic.
+// Much better than Math.sin() which produces visible patterns.
+const seededRandom = (function() {
+ const cache = {};
+ return function(seed) {
+ if (cache[seed] !== undefined) return cache[seed];
+ let t = (seed + 0x6D2B79F5) | 0;
+ t = Math.imul(t ^ (t >>> 15), t | 1);
+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
+ const result = ((t ^ (t >>> 14)) >>> 0) / 4294967296;
+ cache[seed] = result;
+ return result;
+ };
+})();
// Hide webdriver flag completely
Object.defineProperty(navigator, 'webdriver', {
diff --git a/stealth_test.go b/stealth_test.go
index a10a03ba..da9fe624 100644
--- a/stealth_test.go
+++ b/stealth_test.go
@@ -108,7 +108,7 @@ func TestGenerateFingerprint(t *testing.T) {
OS: "windows",
Browser: "chrome",
},
- wantUA: "Chrome/131",
+ wantUA: "Chrome/" + chromeVersion,
wantPlat: "Win32",
},
{
@@ -117,7 +117,7 @@ func TestGenerateFingerprint(t *testing.T) {
OS: "mac",
Browser: "chrome",
},
- wantUA: "Chrome/131",
+ wantUA: "Chrome/" + chromeVersion,
wantPlat: "MacIntel",
},
{
@@ -126,8 +126,8 @@ func TestGenerateFingerprint(t *testing.T) {
OS: "random",
Browser: "chrome",
},
- wantUA: "Chrome/131", // Should always have Chrome 131
- wantPlat: "", // Could be Win32, MacIntel, or Linux
+ wantUA: "Chrome/" + chromeVersion, // Should use configured chromeVersion
+ wantPlat: "", // Could be Win32, MacIntel, or Linux
},
}