Skip to main content

Python launcher & profile manager for stealth Chromium fingerprint spoofing

Project description

alterbrowser

指纹浏览器 Python 启动 & profile 管理库。将 stealth Chromium 的几十个 --fingerprint-* 开关封装成 Profile dataclass 和一行启动 API。


特性

  • 一行启动AlterBrowser(seed=12345).launch("https://example.com")
  • Profile dataclass:40+ 字段覆盖 UA / GPU / 硬件 / 时区 / 地理 / WebRTC / 字体 / 代理
  • Device Archetype:按真实设备原型(Dell / ThinkPad / MacBook …)派生一致性指纹
  • IP 自适应:自动查询出口 IP,对齐 timezone / geolocation / language / 区域字体
  • 多模式引擎REALISTIC / UNIQUE / CUSTOM 三种指纹策略
  • 字体生成器default / custom / mix / system 四种字体模式
  • CLIpython -m alterbrowser launch --seed 12345 https://example.com
  • 零运行时依赖(仅标准库;socks 代理可选装 PySocks

致谢 (Credits)

本项目借鉴了以下开源项目的代码:

alterbrowser 本身只做 Python 侧的 Profile 管理和 Chrome 命令行组装,底层 Chromium 二进制请自行基于上述项目构建;本仓库不提供 Chromium 源码或二进制。

各项目均有自己的 License,请分别遵守。


安装

暂不发 PyPI。两种用法:

# 方式一:加入 PYTHONPATH
git clone <this-repo> alterbrowser
python -c "import alterbrowser; print(alterbrowser.__version__)"

# 方式二:editable install(需要 Python ≥ 3.9)
pip install -e ./alterbrowser

配置 chrome 路径(可选,否则用打包默认值):

export ALTERBROWSER_CHROME_BINARY="/path/to/your/patched-chrome"
export ALTERBROWSER_PROFILES_DIR="/path/to/profiles"

5 分钟上手

from alterbrowser import AlterBrowser

# 1) 最简:什么都不填,seed 自动用时间戳+熵生成
AlterBrowser().launch("https://example.com")

# 2) 🔥 shorthand:一行指定 GPU / CPU / OS / 分辨率 / 城市(v0.3+)
AlterBrowser(
    gpu="RTX 5090",        # 自动展开成 gpu_vendor/gpu_renderer
    cpu="i9-14900K",       # 自动展开成 hardware_concurrency / device_memory
    os="win11",            # 自动展开成 platform / platform_version
    resolution="4K",       # 自动展开成 screen_width/height(也支持 "1920x1080")
    city="Shanghai",       # 自动展开成 timezone / geolocation / language
).launch("https://example.com")

# 3) 想要可复现?显式传 seed
AlterBrowser(seed=12345, city="Shanghai").launch()

# 4) 从 Device Archetype 派生(市场权重随机挑一个真实机型)
sb = AlterBrowser.from_archetype("dell_latitude_e6430_2012")
sb.adapt_to_ip()           # 按出口 IP 自动对齐时区/地理/语言/字体
sb.launch("https://example.com")

# 5) 持久化
sb.save("profile_001.json")
AlterBrowser.load("profile_001.json").launch()

Shorthand 支持的写法(大小写和空白不敏感):

字段 示例
gpu "RTX 5090" / "RX 7900 XTX" / "Arc A770" / "UHD 630" / "M2 Pro" / 任意自由字符串
cpu "i9-14900K" / "Ryzen 9 7950X" / "M3 Max"
os "win11" / "Windows 10" / "macos 14" / "Sonoma" / "Ubuntu"
resolution "1920x1080" / "4K" / "qhd" / "1440p"
city "Shanghai" / "NYC" / "Tokyo" / "Hong Kong" / "London" / 30+ 大城市

不在预设表的显卡名会按品牌关键词识别(nvidia/radeon/intel/apple),其他字段 fallback 为 no-op。用户显式设置的底层字段始终优先于 shorthand。

关于 seed:v0.3.1 起完全可选,不传则用"纳秒时间戳 XOR 系统熵"自动生成。seed 只决定 ① fingerprint_mode=UNIQUE 下传给 Chrome 的指纹种子 ② 字体混合/variant 选择等确定性派生 ③ user-data-dir 默认命名。想可复现时再显式传。

更多场景示例见 docs/USAGE.md,所有 API 细节见 docs/API.md


字体模式速查

模式 含义 使用场景
default 不传 --fingerprint-fonts,由上游 seed-hiding 控制 多 profile,追求自动化差异
custom fonts_custom 作为严格白名单 高级用户精确控制
mix 混合风格(Windows + macOS + Linux + Google 混合 70–120 字体) 标准多账号场景
system 读系统实际安装字体作为白名单 最像真实浏览器

项目结构

alter_browser/                 ← repo 根
├── alterbrowser/              ← Python 包
│   ├── __init__.py            公开 API 导出
│   ├── __main__.py            CLI 入口
│   ├── browser.py             AlterBrowser 顶层类
│   ├── profile.py             Profile / ProfileBatch dataclass
│   ├── modes.py               FingerprintMode / SourceMode / WebRTCMode / TriState 枚举
│   ├── fonts.py               FontMode / FontGenerator
│   ├── archetype.py           Device Archetype 桥接
│   ├── ip_adapt.py            IP 自适应
│   ├── switches.py            命令行开关构建器
│   ├── launcher.py            subprocess 启动器
│   ├── errors.py              异常类型
│   └── utils.py               seed 派生 / 随机工具
├── tests/                     单元测试 (44 cases)
├── docs/
│   ├── USAGE.md               基础操作指南
│   └── API.md                 完整 API 参考
├── pyproject.toml
├── LICENSE
├── .gitignore
└── README.md

运行测试

pytest tests/ -v

版本

  • v0.3.1seed 改为完全可选;不传则用时间戳+熵自动生成
  • v0.3.0 — Shorthand 简写字段(GPU / CPU / OS / Resolution / City 一行搞定)
  • v0.2.1 — Archetype_library 内嵌打包(from_archetype 可直接用)
  • v0.2.0 — Archetype + IP 自适应 + 多模式引擎(首个 PyPI 发布)
  • v0.1.0 — MVP(Profile + SwitchBuilder + Launcher + CLI + 测试)

License

MIT — 见 LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alterbrowser-0.3.1.tar.gz (52.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alterbrowser-0.3.1-py3-none-any.whl (50.3 kB view details)

Uploaded Python 3

File details

Details for the file alterbrowser-0.3.1.tar.gz.

File metadata

  • Download URL: alterbrowser-0.3.1.tar.gz
  • Upload date:
  • Size: 52.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for alterbrowser-0.3.1.tar.gz
Algorithm Hash digest
SHA256 41238c92222f2329774bf528d78361e05e20d942b11d13af0635a24a261a47ba
MD5 4b5feb5d737a7eaf374e3bfa03609398
BLAKE2b-256 e289f29c64f8aa7759832f2c4e8a89145f6141e61c153875f86f7116856e55ba

See more details on using hashes here.

File details

Details for the file alterbrowser-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: alterbrowser-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 50.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for alterbrowser-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8f64950acbf2416cb3b0c77d96dbf1c6c43f5a23fbaa40a34d446e983f258235
MD5 74429e5c6b3e5435407489aa90432942
BLAKE2b-256 7f01a37eddf3495300f87ce8e745ce7d62af683f55a7c7395155f1a6247c771d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page