From 71461592087f9be9e123eb009fb58d0d3404f520 Mon Sep 17 00:00:00 2001 From: z0ccc Date: Tue, 28 Sep 2021 15:56:04 -0400 Subject: [PATCH] Generating hash from data --- frontend/public/worker.js | 1 - frontend/src/components/Blocks.js | 2 +- frontend/src/components/FingerprintBlock.js | 46 ++-------- frontend/src/components/FingerprintBlock2.js | 61 +++++++++++++ frontend/src/utils/fingerprint.js | 5 ++ frontend/src/utils/other.js | 90 +++++++++----------- 6 files changed, 115 insertions(+), 90 deletions(-) create mode 100644 frontend/src/components/FingerprintBlock2.js create mode 100644 frontend/src/utils/fingerprint.js diff --git a/frontend/public/worker.js b/frontend/public/worker.js index 51662e5..e988ea8 100644 --- a/frontend/public/worker.js +++ b/frontend/public/worker.js @@ -2,7 +2,6 @@ const data = { locale: Intl.DateTimeFormat().resolvedOptions().locale, timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone, timezoneOffset: new Date().getTimezoneOffset(), - date: new Date().toString(), deviceMemory: navigator.deviceMemory, hardwareConcurrency: navigator.hardwareConcurrency, platform: navigator.platform, diff --git a/frontend/src/components/Blocks.js b/frontend/src/components/Blocks.js index 8901bed..36af9d2 100644 --- a/frontend/src/components/Blocks.js +++ b/frontend/src/components/Blocks.js @@ -29,7 +29,7 @@ const Blocks = () => { {connectionData ? ( <>
- {/* */} + diff --git a/frontend/src/components/FingerprintBlock.js b/frontend/src/components/FingerprintBlock.js index 805487e..a3e0bb9 100644 --- a/frontend/src/components/FingerprintBlock.js +++ b/frontend/src/components/FingerprintBlock.js @@ -1,54 +1,24 @@ +/* eslint-disable no-unused-vars */ import { useState } from 'react'; import Block from './Block'; import Table from './Table'; -import { - getHardware, - getWebGL, - getSoftware, - getFingerprint, - getHash, - getName, - handleSave, -} from './mainOld'; +import getHash from '../utils/fingerprint'; -const FingerprintBlock = () => { - const [name, setName] = useState(''); - const [load, setLoad] = useState(false); - const [saved, setSaved] = useState(''); - const hash = getHash([...getHardware(), ...getWebGL(), ...getSoftware()]); - getName(hash, setName, setLoad); +const FingerprintBlock = ({ workerData }) => { + const hash = getHash(workerData); + console.log(hash); return (

Fingerprint

- {load && ( - <> - {name ? ( - - ) : ( -
-
{hash}
-
- )} - - )} +
+
{hash}
+

Explanation: This is a unique identifier that can be used to follow you around the web. Even if you clear cookies, change your IP or use private mode the hash will stay the same. Enter your name below and reload the page in private mode to test it out.

- {saved ? ( -

Success! Re-scan browser.

- ) : ( - { - handleSave(e, hash, setSaved); - }} - > - - - - )} ); }; diff --git a/frontend/src/components/FingerprintBlock2.js b/frontend/src/components/FingerprintBlock2.js new file mode 100644 index 0000000..a67830f --- /dev/null +++ b/frontend/src/components/FingerprintBlock2.js @@ -0,0 +1,61 @@ +import { useState } from 'react'; +import Block from './Block'; +import Table from './Table'; +import { + getHardware, + getWebGL, + getSoftware, + getFingerprint, + getHash, + getName, + handleSave, +} from './mainOld'; + +const FingerprintBlock = () => { + const [name, setName] = useState(''); + const [load, setLoad] = useState(false); + const [saved, setSaved] = useState(''); + const hash = getHash([...getHardware(), ...getWebGL(), ...getSoftware()]); + getName(hash, setName, setLoad); + return ( + +

Fingerprint

+ {load && ( + <> + {name ? ( +
+ ) : ( +
+
{hash}
+
+ )} + + )} +

+ Explanation: This is a unique identifier that can be used to + follow you around the web. Even if you clear cookies, change your IP or + use private mode the hash will stay the same. Enter your name below and + reload the page in private mode to test it out. +

+ {saved ? ( +

Success! Re-scan browser.

+ ) : ( + { + handleSave(e, hash, setSaved); + }} + > + + + + )} + + ); +}; + +export default FingerprintBlock; diff --git a/frontend/src/utils/fingerprint.js b/frontend/src/utils/fingerprint.js new file mode 100644 index 0000000..7a4ea57 --- /dev/null +++ b/frontend/src/utils/fingerprint.js @@ -0,0 +1,5 @@ +import md5 from 'crypto-js/md5'; + +const getHash = (data) => md5(JSON.stringify(data)).toString(); + +export default getHash; diff --git a/frontend/src/utils/other.js b/frontend/src/utils/other.js index 907df1f..751860d 100644 --- a/frontend/src/utils/other.js +++ b/frontend/src/utils/other.js @@ -1,4 +1,3 @@ -/* eslint-disable no-unused-vars */ import { checkWebWorker } from './common'; const detectTor = () => { @@ -22,54 +21,45 @@ const checkDatePrototype = () => { }; // Returns object with location data -const getOther = (battery, adBlock, workerData) => { - const workerAgentParsed = 1; - return [ - { - key: 'Brave browser', - value: navigator.brave ? 'True' : 'False', - issues: [checkWebWorker], - }, - { - key: 'Tor browser', - value: detectTor() ? 'True' : 'False', - issues: [], - }, - { - key: 'Adblock', - value: adBlock ? 'True' : 'False', - issues: [], - }, - { - key: 'Date', - value: new Date().toString(), - issues: [ - checkDatePrototype(), - checkWebWorker(new Date().toString(), workerData.date), - ], - }, - { - key: 'Timezone offset', - value: new Date().getTimezoneOffset(), - issues: [ - checkDatePrototype(), - checkWebWorker( - new Date().getTimezoneOffset(), - workerData.timezoneOffset - ), - ], - }, - { - key: 'Battery level', - value: `${Math.round(battery.level * 100)}%`, - issues: [], - }, - { - key: 'Battery status', - value: battery.charging ? 'Charging' : 'Not charging', - issues: [], - }, - ]; -}; +const getOther = (battery, adBlock, workerData) => [ + { + key: 'Brave browser', + value: navigator.brave ? 'True' : 'False', + issues: [checkWebWorker], + }, + { + key: 'Tor browser', + value: detectTor() ? 'True' : 'False', + issues: [], + }, + { + key: 'Adblock', + value: adBlock ? 'True' : 'False', + issues: [], + }, + { + key: 'Date', + value: new Date().toString(), + issues: [checkDatePrototype()], + }, + { + key: 'Timezone offset', + value: new Date().getTimezoneOffset(), + issues: [ + checkDatePrototype(), + checkWebWorker(new Date().getTimezoneOffset(), workerData.timezoneOffset), + ], + }, + { + key: 'Battery level', + value: `${Math.round(battery.level * 100)}%`, + issues: [], + }, + { + key: 'Battery status', + value: battery.charging ? 'Charging' : 'Not charging', + issues: [], + }, +]; export default getOther;