Added fingerprint functions to main file
This commit is contained in:
parent
4353d95b56
commit
9b7798f5ac
3 changed files with 66 additions and 115 deletions
|
|
@ -1,65 +1,32 @@
|
||||||
/* eslint-disable no-unused-vars */
|
/* eslint-disable no-unused-vars */
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import axios from 'axios';
|
|
||||||
import ScanBlock from './ScanBlock';
|
import ScanBlock from './ScanBlock';
|
||||||
import Table from './Table';
|
import Table from './Table';
|
||||||
import { getHash, getHardware, getWebGL, getBattery } from './main';
|
import {
|
||||||
|
getHardware,
|
||||||
|
getWebGL,
|
||||||
|
getSoftware,
|
||||||
|
getFingerprint,
|
||||||
|
getHash,
|
||||||
|
getName,
|
||||||
|
handleSave,
|
||||||
|
} from './main';
|
||||||
|
|
||||||
const FingerprintBlock = () => {
|
const FingerprintBlock = () => {
|
||||||
const [data, setData] = useState([]);
|
|
||||||
const [name, setName] = useState('');
|
const [name, setName] = useState('');
|
||||||
const [saved, setSaved] = useState('');
|
const [saved, setSaved] = useState('');
|
||||||
const [display, setDisplay] = useState('none');
|
const hash = getHash([...getHardware(), ...getWebGL(), ...getSoftware()]);
|
||||||
|
getName(hash, setName);
|
||||||
useEffect(() => {
|
|
||||||
setData([...getHardware(), ...getWebGL()]);
|
|
||||||
|
|
||||||
axios
|
|
||||||
.get(`https://api.vytal.io/fingerprint/?hash=${hash}`)
|
|
||||||
.then((response) => {
|
|
||||||
if (response.data.length !== 0) {
|
|
||||||
setName(response.data[response.data.length - 1].name);
|
|
||||||
}
|
|
||||||
setDisplay('block');
|
|
||||||
});
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleSave = (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
axios.post('https://api.vytal.io/fingerprint/', {
|
|
||||||
name: e.target[0].value,
|
|
||||||
hash,
|
|
||||||
});
|
|
||||||
setSaved(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
const hash = getHash(data);
|
|
||||||
|
|
||||||
const tableData = [
|
|
||||||
{
|
|
||||||
key: 'name',
|
|
||||||
title: 'Name',
|
|
||||||
value: name,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'hash',
|
|
||||||
title: 'Hash',
|
|
||||||
value: hash,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScanBlock>
|
<ScanBlock>
|
||||||
<h1>Fingerprint</h1>
|
<h1>Fingerprint</h1>
|
||||||
<div style={{ display }}>
|
{name ? (
|
||||||
{name ? (
|
<Table data={getFingerprint(name, hash)} />
|
||||||
<Table data={tableData} />
|
) : (
|
||||||
) : (
|
<div className="boxWrap">
|
||||||
<div className="boxWrap">
|
<div className="hash">{hash}</div>
|
||||||
<div className="hash">{hash}</div>
|
</div>
|
||||||
</div>
|
)}
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<p>
|
<p>
|
||||||
<b>Explanation:</b> This is a unique identifier that can be used to
|
<b>Explanation:</b> This is a unique identifier that can be used to
|
||||||
follow you around the web. Even if you clear cookies, change your IP or
|
follow you around the web. Even if you clear cookies, change your IP or
|
||||||
|
|
@ -71,7 +38,7 @@ const FingerprintBlock = () => {
|
||||||
) : (
|
) : (
|
||||||
<form
|
<form
|
||||||
onSubmit={(e) => {
|
onSubmit={(e) => {
|
||||||
handleSave(e);
|
handleSave(e, hash, setSaved);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<input type="text" id="name" name="name" placeholder="Enter name" />
|
<input type="text" id="name" name="name" placeholder="Enter name" />
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import ScanBlock from './ScanBlock';
|
||||||
import Table from './Table';
|
import Table from './Table';
|
||||||
import { getSoftware } from './main';
|
import { getSoftware } from './main';
|
||||||
|
|
||||||
const HardwareBlock = () => (
|
const SoftwareBlock = () => (
|
||||||
<ScanBlock>
|
<ScanBlock>
|
||||||
<h1>Software</h1>
|
<h1>Software</h1>
|
||||||
<Table data={getSoftware()} />
|
<Table data={getSoftware()} />
|
||||||
|
|
@ -13,4 +13,4 @@ const HardwareBlock = () => (
|
||||||
</ScanBlock>
|
</ScanBlock>
|
||||||
);
|
);
|
||||||
|
|
||||||
export default HardwareBlock;
|
export default SoftwareBlock;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import md5 from 'crypto-js/md5';
|
import md5 from 'crypto-js/md5';
|
||||||
import Bowser from 'bowser';
|
import Bowser from 'bowser';
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
const getHardware = () => {
|
const getHardware = () => {
|
||||||
const data = [
|
const data = [
|
||||||
|
|
@ -192,67 +193,50 @@ const sortPlugins = (data) => {
|
||||||
return list;
|
return list;
|
||||||
};
|
};
|
||||||
|
|
||||||
// const getFingerprint = () => {
|
const getFingerprint = (name, hash) => {
|
||||||
// const data = [
|
const data = [
|
||||||
// {
|
{
|
||||||
// key: 'name',
|
key: 'name',
|
||||||
// title: 'Name',
|
title: 'Name',
|
||||||
// value: name,
|
value: name,
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// key: 'hash',
|
key: 'hash',
|
||||||
// title: 'Hash',
|
title: 'Hash',
|
||||||
// value: hash,
|
value: hash,
|
||||||
// },
|
},
|
||||||
// ];
|
];
|
||||||
// return data;
|
return data;
|
||||||
|
};
|
||||||
// const data = [
|
|
||||||
// {
|
|
||||||
// key: 'platform',
|
|
||||||
// value: navigator.platform,
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// key: 'userAgent',
|
|
||||||
// value: navigator.userAgent,
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// key: 'preferredLanguage',
|
|
||||||
// value: navigator.language,
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// key: 'languages',
|
|
||||||
// title: 'Languages',
|
|
||||||
// value: navigator.languages,
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// key: 'timezone',
|
|
||||||
// value: Intl.DateTimeFormat().resolvedOptions().timeZone || 'N/A',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// key: 'cookiesEnabled',
|
|
||||||
// value: navigator.cookieEnabled,
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// key: 'javaEnabled',
|
|
||||||
// value: navigator.javaEnabled(),
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// key: 'dntHeader',
|
|
||||||
// value: navigator.doNotTrack,
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// key: 'automatedBrowser',
|
|
||||||
// value: navigator.webdriver,
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// key: 'plugins',
|
|
||||||
// value: navigator.plugins,
|
|
||||||
// },
|
|
||||||
// ];
|
|
||||||
// return data;
|
|
||||||
// };
|
|
||||||
|
|
||||||
const getHash = (data) => md5(JSON.stringify(data)).toString();
|
const getHash = (data) => md5(JSON.stringify(data)).toString();
|
||||||
|
|
||||||
export { getHash, getSoftware, getHardware, getWebGL, getBattery };
|
const getName = (hash, setName) => {
|
||||||
|
axios
|
||||||
|
.get(`https://api.vytal.io/fingerprint/?hash=${hash}`)
|
||||||
|
.then((response) => {
|
||||||
|
if (response.data.length !== 0) {
|
||||||
|
setName(response.data[response.data.length - 1].name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSave = (e, hash, setSaved) => {
|
||||||
|
e.preventDefault();
|
||||||
|
axios.post('https://api.vytal.io/fingerprint/', {
|
||||||
|
name: e.target[0].value,
|
||||||
|
hash,
|
||||||
|
});
|
||||||
|
setSaved(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
export {
|
||||||
|
getSoftware,
|
||||||
|
getHardware,
|
||||||
|
getWebGL,
|
||||||
|
getBattery,
|
||||||
|
getFingerprint,
|
||||||
|
getHash,
|
||||||
|
getName,
|
||||||
|
handleSave,
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue