This document explains how browser plugin fingerprints are obtained and generated. It covers using JavaScript to retrieve plugin information, encrypting it with the SHA-256 algorithm, and the specific method for implementing fingerprint randomization within the Chromium compilation process.
1. What is a Plugin Fingerprint?
"Plugin fingerprinting" is a type of online tracking technology. It works by collecting information about installed browser plugins and consolidating it to form a unique identifier. However, the uniqueness of a plugin fingerprint alone is relatively low; it is typically combined with other fingerprints to be more effective.
2. How to Get Your Own Plugin Fingerprint
Copy the following code into the F12 console to display your plugin fingerprint.
js
async function sha256(message) {
const msgBuffer = new TextEncoder().encode(message);
const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
return hashHex;
}
function getPluginsString() {
if (navigator.plugins === undefined || navigator.plugins.length === 0) {
return 'no plugins';
}
var pluginsString = [];
for (var i = 0; i < navigator.plugins.length; i++) {
var plugin = navigator.plugins[i];
var pluginString = plugin.name + '::' + plugin.description + '::' + plugin.filename;
var mimeTypes = [];
for (var j = 0; j < plugin.length; j++) {
var mimeType = plugin[j];
mimeTypes.push(mimeType.type + '~' + mimeType.suffixes);
}
if (mimeTypes.length > 0) {
pluginString += '::' + mimeTypes.join(',');
}
pluginsString.push(pluginString);
}
return pluginsString.join(';');
}
var pluginsFingerprint = getPluginsString();
sha256(pluginsFingerprint).then(hash => console.log(hash));
Output:
e336f0bfce56a91fd1fd0a88530f3bf323ad23cf6155769cc89b09092880cde9
3. How to Compile
Open the source file: third_party/blink/renderer/modules/plugins/dom_plugin.cc
①Add these includes at the top:
c
#include <random>
#include <string>
②Locate the following code:
c
String DOMPlugin::description() const {
return plugin_info_->Description();
}
③Replace the original code with:
c
int getRandomIntForFoo8Modern() {
static std::mt19937 generator(static_cast<unsigned long>(time(NULL))); // 静态以确保只初始化一次
std::uniform_int_distribution<int> distribution(0, 9);
return distribution(generator);
}
String DOMPlugin::description() const {
//return plugin_info_->Description();
String tmp = plugin_info_->Description();
return tmp + String(std::to_string(getRandomIntForFoo8Modern()));
}
After compilation, the plugin fingerprint will be randomized upon each refresh.
ninja -C out/Default chrome