🔥 GitHub 10,558星 · 今日+1,369

隐身浏览器自动化:CloakBrowser反检测技术详解

凌晨1点55分,CloakBrowser的README上写着"30/30 tests passed"——30项反检测测试全部通过。10,558颗星在暗夜中闪烁,仿佛在说:"那些号称能识破所有自动化工具的网站,其实也不过如此。"这个项目本质上是在做一件极其硬核的事:让机器看起来像人

这不是教你做坏事,而是Agent时代的基础设施——合法的数据采集、自动化测试、竞品监控,都需要绕过那些过于敏感的bot检测。

Creep.js
Pixelscan
BrowserLeaks
Cloudflare
reCAPTCHA

什么是隐身浏览器

隐身浏览器(Stealth Browser)是一种经过指纹伪装的自动化浏览器,能够绕过主流网站的bot检测系统。

为什么普通自动化浏览器会被检测?

检测维度普通PlaywrightCloakBrowser
Navigator.webdrivertrue ❌false ✅
Chrome Runtime缺失 ❌完整 ✅
Canvas指纹固定值 ❌随机化 ✅
WebGL指纹固定值 ❌随机化 ✅
AudioContext固定值 ❌随机化 ✅
字体列表空列表 ❌模拟真实 ✅
插件列表空列表 ❌模拟Chrome ✅
语言/时区默认值 ❌一致性匹配 ✅
鼠标轨迹直线 ❌贝塞尔曲线 ✅
请求头固定值 ❌动态生成 ✅

CloakBrowser技术架构

三层防护体系

# CloakBrowser防护架构
┌─────────────────────────────────┐
│   Layer 3: 行为模拟层            │
│   - 人类式鼠标轨迹               │
│   - 自然滚动模式                 │
│   - 随机延迟                     │
│   - 打字速度变化                 │
├─────────────────────────────────┤
│   Layer 2: 指纹伪装层            │
│   - Canvas/WebGL随机化           │
│   - AudioContext噪声注入         │
│   - 字体/插件列表模拟            │
│   - 屏幕分辨率/颜色深度伪装       │
├─────────────────────────────────┤
│   Layer 1: 源码修改层            │
│   - 移除webdriver标记            │
│   - 补全Chrome Runtime           │
│   - 修正Navigator属性            │
│   - 伪装CDP连接                  │
└─────────────────────────────────┘

源码级修改

# CloakBrowser核心修改(简化版)

# 1. 移除webdriver标记
# 原始Chromium代码
Object.defineProperty(navigator, 'webdriver', { get: () => true });
# CloakBrowser修改
Object.defineProperty(navigator, 'webdriver', { get: () => undefined });

# 2. Canvas指纹随机化
# 在Canvas API层面注入微小噪声
const originalGetContext = HTMLCanvasElement.prototype.getContext;
HTMLCanvasElement.prototype.getContext = function(type, attrs) {
    const ctx = originalGetContext.call(this, type, attrs);
    if (type === '2d') {
        const originalToDataURL = this.toDataURL;
        this.toDataURL = function(...args) {
            // 添加人眼不可见的随机噪声
            const imageData = ctx.getImageData(0, 0, this.width, this.height);
            for (let i = 0; i < imageData.data.length; i += 4) {
                imageData.data[i] += (Math.random() - 0.5) * 2; // R
            }
            ctx.putImageData(imageData, 0, 0);
            return originalToDataURL.apply(this, args);
        };
    }
    return ctx;
};

# 3. WebGL指纹随机化
# 修改WebGL renderer/vendor信息
const originalGetParameter = WebGLRenderingContext.prototype.getParameter;
WebGLRenderingContext.prototype.getParameter = function(param) {
    if (param === 0x1F01) return 'Google Inc. (NVIDIA)'; // Vendor
    if (param === 0x1F02) return 'ANGLE (NVIDIA, NVIDIA GeForce GTX 1660)'; // Renderer
    return originalGetParameter.call(this, param);
};

行为模拟技术

人类式鼠标轨迹

# 贝塞尔曲线鼠标移动
import numpy as np

def human_mouse_move(start, end, duration_ms=500):
    """生成人类式的鼠标移动轨迹"""
    # 生成2-3个随机控制点
    control_points = []
    for _ in range(np.random.randint(2, 4)):
        cx = np.random.uniform(min(start[0], end[0]), max(start[0], end[0]))
        cy = np.random.uniform(min(start[1], end[1]), max(start[1], end[1]))
        control_points.append((cx, cy))
    
    # 贝塞尔曲线插值
    points = bezier_curve(start, control_points, end, steps=50)
    
    # 添加速度变化(起始慢 → 中间快 → 结束慢)
    timestamps = ease_in_out_easing(len(points), duration_ms)
    
    # 添加微小随机偏移
    for i, (x, y) in enumerate(points):
        if i > 0 and i < len(points) - 1:
            points[i] = (x + np.random.normal(0, 0.5), y + np.random.normal(0, 0.5))
    
    return list(zip(points, timestamps))

def ease_in_out_easing(n, total_ms):
    """生成人类式的加速-减速时间分布"""
    t = np.linspace(0, 1, n)
    # 快速中间加速
    eased = t ** 0.3 * (3 - 2 * t)
    return (eased * total_ms).astype(int).tolist()

自然滚动模式

# 人类式滚动
def human_scroll(page, target_y):
    """模拟人类滚动行为"""
    current_y = page.evaluate("window.scrollY")
    distance = target_y - current_y
    
    # 随机滚动步长(100-300px)
    step_size = np.random.randint(100, 300)
    
    while abs(target_y - current_y) > step_size:
        # 随机决定向上还是向下滚动
        direction = 1 if target_y > current_y else -1
        scroll_amount = direction * step_size
        
        # 有时候滚动过头再滚回来
        if np.random.random() < 0.1:
            scroll_amount *= -0.3
        
        page.evaluate(f"window.scrollBy(0, {scroll_amount})")
        current_y = page.evaluate("window.scrollY")
        
        # 随机停顿(50-500ms)
        time.sleep(np.random.uniform(0.05, 0.5))

OpenClaw/Camofox实战

Camofox vs CloakBrowser

# OpenClaw内置的Camofox已实现类似功能

# 使用Camofox创建隐身标签页
camofox_create_tab({
    url: "https://example.com"
})

# Camofox自动处理:
# - 反指纹检测
# - 人类式行为模拟
# - 动态请求头

# 截取快照
camofox_snapshot({ tabId: "tab_xxx" })

# 人类式点击
camofox_click({ tabId: "tab_xxx", ref: "e12" })

# 人类式输入
camofox_type({ 
    tabId: "tab_xxx", 
    ref: "e5", 
    text: "搜索关键词",
    pressEnter: false
})

Agent自动化场景

# 场景1:竞品价格监控
# 每小时检查竞品网站价格

camofox_navigate({
    tabId: "tab_xxx",
    url: "https://competitor.com/products/123"
})

snapshot = camofox_snapshot({ tabId: "tab_xxx" })
# 解析价格信息...

# 场景2:社媒内容采集
# 搜索行业关键词,采集相关帖子

camofox_navigate({
    tabId: "tab_xxx",
    macro: "@google_search",
    query: "AI Agent 2026 最新动态"
})

# 场景3:SEO检查
# 检查网站在不同搜索引擎中的排名

camofox_navigate({
    tabId: "tab_xxx",
    url: "https://www.google.com/search?q=miaoquai+OpenClaw教程"
})

反检测测试网站

验证隐身效果的常用测试网站:

30项测试覆盖的检测平台

  • CreepJS - 综合浏览器指纹分析
  • Pixelscan - IP+浏览器指纹综合评分
  • BrowserLeaks - 详细指纹信息泄露检测
  • Cloudflare Turnstile - Cloudflare反机器人验证
  • reCAPTCHA - Google人机验证
  • Arkose Labs - 高级行为分析
  • Incapsula/Imperva - WAF反机器人
  • DataDome - AI驱动的bot检测
  • PerimeterX - 实时行为分析
  • FingerprintJS - 浏览器指纹库

合法使用边界

✅ 合法用途

  • 数据采集:公开数据的自动化采集
  • 自动化测试:网站功能测试
  • 竞品监控:公开价格/信息监控
  • SEO审计:搜索排名检查
  • 辅助功能测试:网站无障碍检查

❌ 违规使用

  • 绕过登录认证获取私有数据
  • 大规模爬取受保护的版权内容
  • 恶意抢购/刷单
  • Ddos攻击
  • 钓鱼攻击