Catching basic object tampering

This commit is contained in:
z0ccc 2021-09-01 15:49:55 -04:00
parent 539261dd8f
commit 990a94bced
5 changed files with 136 additions and 15 deletions

View file

@ -17,7 +17,7 @@ const NavigatorBlock = () => {
return ( return (
<ScanBlock> <ScanBlock>
<h1>Hardware</h1> <h1>Navigator</h1>
<NewTable data={getNavigator()} /> <NewTable data={getNavigator()} />
<p> <p>
<b>Explanation:</b> JavaScript can be used to find information about <b>Explanation:</b> JavaScript can be used to find information about

View file

@ -1,12 +1,14 @@
import { checkUndefinedProperties } from './navigator';
const Table = ({ data }) => ( const Table = ({ data }) => (
<div className="tableWrap"> <div className="tableWrap">
<table> <table>
{data.map((item) => ( {data.map((item) => (
<tbody key={item.title}> <tbody key={item.key}>
<tr> <tr>
<td>{item.title}</td> <td>{item.title}</td>
<td>{item.value}</td> <td>{item.value}</td>
<td>{item.test}</td> <td>{checkUndefinedProperties(item)}</td>
</tr> </tr>
</tbody> </tbody>
))} ))}

View file

@ -1,3 +1,4 @@
/* eslint-disable no-unused-vars */
import NavigatorBlock from './NavigatorBlock'; import NavigatorBlock from './NavigatorBlock';
import FingerprintBlock from './FingerprintBlock'; import FingerprintBlock from './FingerprintBlock';
import LocationBlock from './LocationBlock'; import LocationBlock from './LocationBlock';
@ -10,12 +11,12 @@ import FiltersBlock from './FiltersBlock';
const ScanBlocks = () => ( const ScanBlocks = () => (
<> <>
<NavigatorBlock /> <NavigatorBlock />
<FingerprintBlock /> {/* <FingerprintBlock />
<LocationBlock /> <LocationBlock />
<ConnectionBlock /> <ConnectionBlock />
<FiltersBlock /> <FiltersBlock />
<SoftwareBlock /> <SoftwareBlock />
<HardwareBlock /> <HardwareBlock /> */}
{/* <FontsBlock /> */} {/* <FontsBlock /> */}
</> </>
); );

View file

@ -1,5 +1,4 @@
/* eslint-disable import/prefer-default-export */ export { getNavigator, checkUndefinedProperties };
export { getNavigator };
const getNavigator = () => { const getNavigator = () => {
const data = [ const data = [
@ -7,17 +6,136 @@ const getNavigator = () => {
key: 'deviceMemory', key: 'deviceMemory',
title: 'Device memory', title: 'Device memory',
value: navigator.deviceMemory ? `${navigator.deviceMemory}GB` : 'N/A', value: navigator.deviceMemory ? `${navigator.deviceMemory}GB` : 'N/A',
test: },
checkUndefinedProperties('deviceMemory') && {
'failed undefined properties', key: 'hardwareConcurrency',
title: 'Hardware Concurrency',
value: navigator.hardwareConcurrency || 'N/A',
},
{
key: 'maxTouchPoints',
title: 'Max touchpoints',
value: navigator.maxTouchPoints || 'N/A',
},
{
key: 'platform',
title: 'Platform',
value: navigator.platform || 'N/A',
},
{
key: 'userAgent',
title: 'User agent',
value: navigator.userAgent || 'N/A',
},
{
key: 'language',
title: 'Language',
value: navigator.language || 'N/A',
},
{
key: 'languages',
title: 'Languages',
value: navigator.languages || 'N/A',
},
{
key: 'cookieEnabled',
title: 'Cookies enabled',
value: navigator.cookieEnabled ? 'True' : 'False',
},
{
key: 'doNotTrack',
title: 'Do not track header',
value: navigator.doNotTrack ? 'True' : 'False',
},
{
key: 'webdriver',
title: 'Webdriver',
value: navigator.webdriver ? 'True' : 'False',
},
{
key: 'plugins',
title: 'Plugins',
value: sortPlugins(navigator.plugins) || 'N/A',
},
// {
// key: 'connection',
// title: 'Connection',
// value: JSON.stringify(navigator.connection) || 'N/A',
// prototype: Navigator.prototype.hardwareConcurrency,
// },
// {
// key: 'geolocation',
// title: 'Geolocation',
// value: navigator.geolocation || 'N/A',
// prototype: Navigator.prototype.hardwareConcurrency,
// },
// {
// key: 'hid',
// title: 'Hid',
// value: navigator.hid || 'N/A',
// prototype: Navigator.prototype.hardwareConcurrency,
// },
// {
// key: 'keyboard',
// title: 'Keyboard',
// value: navigator.keyboard || 'N/A',
// prototype: Navigator.prototype.hardwareConcurrency,
// },
{
key: 'onLine',
title: 'Online',
value: navigator.onLine ? 'True' : 'False',
},
{
key: 'vendor',
title: 'Vendor',
value: navigator.vendor || 'N/A',
},
{
key: 'appVersion',
title: 'App version',
value: navigator.appVersion || 'N/A',
},
{
key: 'productSub',
title: 'Product sub',
value: navigator.productSub || 'N/A',
},
{
key: 'vendorSub',
title: 'Vendor sub',
value: navigator.vendorSub || 'N/A',
}, },
]; ];
return data; return data;
}; };
const checkUndefinedProperties = (property) => { // sorts plugins object into comma separated list
if (Object.getOwnPropertyDescriptor(navigator, property) !== undefined) { const sortPlugins = (data) => {
return true; const { length } = data;
let list = '';
for (let i = 0; i < length; i++) {
if (i !== 0) list += ', ';
list += data[i].name;
} }
return false; return list;
};
const checkUndefinedProperties = (obj) => {
const list = [];
if (Object.getOwnPropertyDescriptor(navigator, obj.key) !== undefined) {
list.push('Failed undefined properties');
}
if (
Object.getOwnPropertyDescriptor(Navigator.prototype, obj.key).value !==
undefined
) {
list.push('Failed descriptor.value undefined');
}
// console.log(obj.prototype.constructor.name);
// if (obj.prototype.constructor.name === 'Number') {
// list.push('Failed constructor name');
// }
return list;
}; };

View file

@ -41,7 +41,7 @@
} }
.centerBlockInner { .centerBlockInner {
width: 650px; width: 800px;
margin: 24px 0 0 0; margin: 24px 0 0 0;
} }