场景:多套独立的隔离环境
指纹生成py
""" fpfile 批量生成器 生成10个不同的 profileN.txt,适合 ruyiPage + firefox-fingerprintBrowser 重点随机:canvas 种子 + 部分硬件/分辨率"""importrandom from pathlibimportPath# ==================== 配置区域 ====================OUTPUT_DIR=Path(r"C:\Users\qinqin\Desktop\ruyipage\test\fingerprints")NUM_PROFILES=10# 基础模板(日本风格,可自行改成美国/其他)BASE_CONFIG="""webdriver:0 local_webrtc_ipv4:104.251.229.181 local_webrtc_ipv6:2001:db8::1234 public_webrtc_ipv4:104.251.229.181 public_webrtc_ipv6:2001:db8::5678 timezone:Asia/Tokyo language:ja-JP,ja font_system:windows useragent:Mozilla/5.0(Windows NT10.0;Win64;x64;rv:147.0)Gecko/20100101 Firefox/147.0 hardwareConcurrency:16 webgl.vendor:Google Inc.(AMD)webgl.renderer:ANGLE(AMD, AMD Radeon RX6800XT Direct3D11 vs_5_0 ps_5_0, D3D11)webgl.version:WebGL1.0(OpenGL ES2.0Chromium)webgl.glsl_version:WebGL GLSL ES1.0(OpenGL ES GLSL ES1.0Chromium)webgl.unmasked_vendor:Google Inc.(AMD)webgl.unmasked_renderer:ANGLE(AMD, AMD Radeon RX6800XT Direct3D11 vs_5_0 ps_5_0, D3D11)webgl.max_texture_size:16384 webgl.max_cube_map_texture_size:16384 webgl.max_texture_image_units:32 webgl.max_vertex_attribs:16 webgl.aliased_point_size_max:1024 webgl.max_viewport_dim:16384 width:1920 height:1080"""# ==================== 生成逻辑 ====================OUTPUT_DIR.mkdir(parents=True,exist_ok=True)foriinrange(1, NUM_PROFILES +1): config=BASE_CONFIG# 关键随机点:canvas 种子(改这个最容易改变 Canvas 指纹)canvas_seed=random.randint(1,9999)config+=f"canvas:{canvas_seed}\n"# 轻微随机屏幕分辨率(常见设备范围)width=random.choice([1366,1440,1536,1920,2560])height=random.choice([768,900,1080,1440])config+=f"width:{width}\n"config+=f"height:{height}\n"# 保存文件file_path=OUTPUT_DIR / f"profile{i}.txt"file_path.write_text(config,encoding="utf-8")print(f"✅ 已生成: {file_path} (canvas:{canvas_seed}, {width}x{height})")print(f"\n🎉 完成!共生成 {NUM_PROFILES} 个 fpfile 文件,路径:{OUTPUT_DIR}")print("你可以直接在 ruyiPage 中使用这些文件实现多套指纹环境。")环境验证+隔离验证:
# -*- coding: utf-8 -*-""" 挨个测试 fpfile 在 creepjs 上的效果"""importtimefrom pathlibimportPath from ruyipageimportFirefoxOptions, FirefoxPage FINGERPRINTS_DIR=Path(r"C:\Users\qinqin\Desktop\ruyipage\test\fingerprints")USER_DIRS_BASE=Path(r"C:\Users\qinqin\Desktop\ruyipage\test\user_dirs")def test_one_profile(profile_num: int): fpfile=FINGERPRINTS_DIR / f"profile{profile_num}.txt"user_dir=USER_DIRS_BASE / f"user{profile_num}"ifnot fpfile.exists(): print(f"❌ profile{profile_num}.txt 不存在")returnopts=FirefoxOptions()opts.set_fpfile(str(fpfile))opts.set_user_dir(str(user_dir))opts.set_port(9300+ profile_num)# 不同端口避免冲突opts.headless(False)opts.set_window_size(1440,900)opts.enable_action_visual(True)opts.close_on_exit(False)print(f"\n🚀 测试第 {profile_num} 套指纹...")print(f" fpfile: {fpfile.name}")page=FirefoxPage(opts)page.get("https://abrahamjuliot.github.io/creepjs/")print(" ✅ 已打开 CreepJS,请观察 Fingerprint ID、Canvas、WebGL 等指标")print(" 记录关键信息后,按 Enter 关闭当前实例并测试下一个...")input(" 按 Enter 继续下一套 → ")page.quit()if__name__=="__main__":USER_DIRS_BASE.mkdir(parents=True,exist_ok=True)foriinrange(1,6):# 先测试前 5 个,你可以改成 10test_one_profile(i)print("\n🎉 全部测试完成!")