By doing tests I am faced with JavaScript fingerprinting such like:
- audio context fingerprinting
- opengl fingerprinting
- canvas fingerprinting
- installed fonts fingerprinting
- installed plugins fingerprinting
- webrtc
I want to replace the results of the fingerprinting with simulated results.
How do fingerprints work and how can I simulate/fake the fingerprinting results?
To change the outcome of these fingerprints, you have to understand how they work. Let's look at an example: The Canvas Fingerprint of browserleaks.com.
How it works
The website will use the browser APIs to produce a Canvas image by painting some text into a canvas. The fingerprint slightly varies in different browsers and machines due to differences in how the rendering is done. For more details check out the "How does it work" part of the page.
Simulate (or fake) the fingerprint
To change the fingerprint, you need to check out which APIs the fingerprint JavaScript of the page is using and replace them with a adapted version.
Code Sample
The following code, replaces the native
HTMLCanvasElement.prototype.toDataURLfunction with a custom function (before any other code is executed on the page). If the function detects that the website is painting an image with a width of220pxand a height of30px, it returns a fake fingerprint. Otherwise, it runs the originaltoDataURLfunction to not mess with any other functionality.Result
Below is the screenshot of the page. Normally, the page would display an image of the fingerprint, but in our case it shows the "Fake Fingerprint" instead. That way, we tricked the page into thinking this is the fingerprint of our browser.
How other fingerprint methods work
Other fingerprint methods work similar. They call existing browser APIs and create a fingerprint based on the results. By replacing all used functions, you could change the fingerprint of the browser. This is a lot of work though, as you have to check how the website is using the APIs and then come up with functions to replace these.