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 (
<ScanBlock>
<h1>Hardware</h1>
<h1>Navigator</h1>
<NewTable data={getNavigator()} />
<p>
<b>Explanation:</b> JavaScript can be used to find information about

View file

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

View file

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

View file

@ -1,5 +1,4 @@
/* eslint-disable import/prefer-default-export */
export { getNavigator };
export { getNavigator, checkUndefinedProperties };
const getNavigator = () => {
const data = [
@ -7,17 +6,136 @@ const getNavigator = () => {
key: 'deviceMemory',
title: 'Device memory',
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;
};
const checkUndefinedProperties = (property) => {
if (Object.getOwnPropertyDescriptor(navigator, property) !== undefined) {
return true;
// sorts plugins object into comma separated list
const sortPlugins = (data) => {
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 {
width: 650px;
width: 800px;
margin: 24px 0 0 0;
}