自定义指纹chromium编译-修改UA,GPU,小版本

JANSON

目标 1
启动 Chrome 时,通过--fingerprints参数传入整数(需为 int 类型,最大值不超过 2,147,483,647),浏览器指纹将固定为该整数对应的唯一值;若更换参数中的整数(仍需符合上述类型和范围要求),则会生成新的对应指纹。
目标 2
启动 Chrome 时不添加--fingerprints参数,浏览器将为每一次访问请求随机生成独立指纹。
(鉴于大家已熟悉源码修改流程,相关操作细节不再赘述)
一、更改显卡(GPU)信息
打开 \third_party\blink\renderer\modules\webgl\webgl_rendering_context_base.cc
在头部追加:

c Copy
#include "base/command_line.h"

找到这个代码:

c Copy
case WebGLDebugRendererInfo::kUnmaskedRendererWebgl:

将原有的return替换掉:

c Copy
case WebGLDebugRendererInfo::kUnmaskedRendererWebgl:
      if (ExtensionEnabled(kWebGLDebugRendererInfoName)) {
        if (IdentifiabilityStudySettings::Get()->ShouldSampleType(
                blink::IdentifiableSurface::Type::kWebGLParameter)) {
          RecordIdentifiableGLParameterDigest(
              pname, IdentifiabilityBenignStringToken(
                         String(ContextGL()->GetString(GL_RENDERER))));
        }
        //return WebGLAny(script_state,
        //                String(ContextGL()->GetString(GL_RENDERER)));
        
        //这里
        base::CommandLine* base_command_line = base::CommandLine::ForCurrentProcess();
        int tmp;
        if (base_command_line->HasSwitch("fingerprints")) {
          std::istringstream(base_command_line->GetSwitchValueASCII("fingerprints")) >> tmp;
        }else{
          auto now = std::chrono::system_clock::now();
          std::time_t now_time_t = std::chrono::system_clock::to_time_t(now);
          tmp = static_cast<int>(now_time_t);
        }
        std::string rstr_1 = std::to_string(tmp % 9);
        std::string rstr_2 = std::to_string(tmp % 7);
        return WebGLAny(script_state, String("ANGLE (NVIDIA, NVIDIA GeForce RTX 40"+rstr_1+"0 Laptop GPU (0x000028A0) Direct3D11 vs_5_0 ps_5_"+rstr_2+", D3D11)"));
        
        }
      SynthesizeGLError(
          GL_INVALID_ENUM, "getParameter",
          "invalid parameter name, WEBGL_debug_renderer_info not enabled");
      return ScriptValue::CreateNull(script_state->GetIsolate());

二、更改userAgent
打开文件:/components/version_info/version_info_with_user_agent.cc
在头部引用:

c Copy
#include <string>
#include <random> 
#include "base/command_line.h"

找到这个代码:

c Copy
std::string GetProductNameAndVersionForReducedUserAgent(
    const std::string& build_version) {
  return base::StrCat(
      {"Chrome/", GetMajorVersionNumber(), ".0.", build_version, ".0"});
}

将原有的函数替换掉:

c Copy
std::string GetProductNameAndVersionForReducedUserAgent(
    const std::string& build_version) {
        
  base::CommandLine* base_command_line = base::CommandLine::ForCurrentProcess();
  std::string tmp = "";
  if (base_command_line->HasSwitch("fingerprints")) {
    tmp = " BigTom/" + base_command_line->GetSwitchValueASCII("fingerprints"); 
  }

  return base::StrCat(
      //{"Chrome/", GetMajorVersionNumber(), ".0.", build_version, ".0"});
      {"Chrome/", GetMajorVersionNumber(), ".0.", build_version, ".0", tmp});
}

其原理是在 User-Agent 中添加一串随机字符。
三、更改内核小版本
1、获取浏览器版本
原理是借助 navigator.userAgentData 来获取。
将下面的代码粘贴至F12控制台,可显示浏览器版本

js Copy
data = await navigator.userAgentData.getHighEntropyValues(
            ['platform', 'platformVersion', 'architecture', 'bitness', 'model', 'uaFullVersion'],
        )
console.debug(data)
console.log(data)

2.找到源码位置
打开 \third_party\blink\renderer\core\frame\navigator_ua.cc

c Copy
ua_data->SetUAFullVersion(String::FromUTF8(metadata.full_version));

替换成

c Copy
 //ua_data->SetUAFullVersion(String::FromUTF8(metadata.full_version));
  
  base::CommandLine* base_command_line = base::CommandLine::ForCurrentProcess();
  int randomNum;
  if (base_command_line->HasSwitch("fingerprints")) {
	int tmp;
    std::istringstream(base_command_line->GetSwitchValueASCII("fingerprints")) >> tmp;
    randomNum = tmp%99;
  }else{
    srand((int)time(NULL));
    randomNum = rand()%99;
  }
  ua_data->SetUAFullVersion("124." + String(std::to_string(randomNum % 99)) +".6572.0");
Update Time:Feb 04, 2026

Comments

Tips: Support some markdown syntax: **bold**, [bold](xxxxxxxxx), `code`, - list, > reference