Skip to content

Commit

Permalink
initial draft
Browse files Browse the repository at this point in the history
  • Loading branch information
Sayrus committed Feb 8, 2020
1 parent 24cedc2 commit d0455ed
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

release:
zip -r build.zip extension
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# AudioContext Scrambler

Protects you against AudioContext fingerprinting by adding random noise.

## What is AudioContext Fingerprinting


## Installation

### From the store

As any addons, navigate to its [store page](https://example.com) and click
`Install`.

### From releases

1. Download the XPI file from Github Releases
2. Navigate to about:addons
3. Install Add-on from file
4. Select the XPI file

#### Build it myself

Use `make release` to create the same XPI file as releases

## Difference with the existing AudioContext Fingerprint Defender

While the prupose is the same, this extension fixes several problems I had with
AFD :
- AFD inject code in the page as a script element
- AFD then inject code in iframes if the document doesn't contain the attribute
`data-acxscriptallow`

This extension uses `exportFunction`. This means that the DOM is not modified.
Unlike AFD, this extension cannot be blocked by setting CSP to `unsafe-inline`
or presetting `data-acxscriptallow` and using iframes.

Finally, this extension has a Github repository so that everyone can participate
and improve it.

## Support

This extension currently only support Firefox and Firefox for Android.

## What's next?

- Notify you when a page is trying to fingerprint you
- Support Chromium
- Configurable noise amplitude
17 changes: 17 additions & 0 deletions extension/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{

"manifest_version": 2,
"name": "AudioContext Scrambler",
"version": "1.0",

"description": "Scramble channel data to avoid AudioContext fingerprinting",

"content_scripts": [
{
"matches": ["*://*/*"],
"run_at": "document_start",
"js": ["scrambler.js"]
}
]

}
33 changes: 33 additions & 0 deletions extension/scrambler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
function createCustomChannelData(target) {
const original = target.prototype.getChannelData;
let buffer = null;
let getChannelData = function () {
const originalResult = original.apply(this, arguments);
if (buffer !== originalResult) {
buffer = originalResult;
for (var i = 0; i < originalResult.length; i += 100) {
let index = Math.floor(Math.random() * i);
originalResult[index] = originalResult[index] + Math.random() * 0.0000001;
}
}
return originalResult;
};
exportFunction(getChannelData, target.prototype, {defineAs:'getChannelData'});
}

function createCustomAnalyserNode(target) {
const original = target.prototype.getFloatFrequencyData;
let getFloatFrequencyData = function () {
const originalResult = original.apply(this, arguments);
for (var i = 0; i < arguments[0].length; i += 100) {
let index = Math.floor(Math.random() * i);
arguments[0][index] = arguments[0][index] + Math.random() * 0.1;
}
return originalResult;
};
exportFunction(getFloatFrequencyData, target.prototype, {defineAs:'getFloatFrequencyData'});
}

createCustomChannelData(window.AudioBuffer);
createCustomChannelData(window.OfflineAudioContext);
createCustomAnalyserNode(window.AnalyserNode);

0 comments on commit d0455ed

Please sign in to comment.