From 990a94bced5026c7ff921be1b207a7cae51d1b01 Mon Sep 17 00:00:00 2001 From: z0ccc Date: Wed, 1 Sep 2021 15:49:55 -0400 Subject: [PATCH] Catching basic object tampering --- frontend/src/components/NavigatorBlock.js | 2 +- frontend/src/components/NewTable.js | 6 +- frontend/src/components/ScanBlocks.js | 5 +- frontend/src/components/navigator.js | 136 ++++++++++++++++++++-- frontend/src/styles/App.css | 2 +- 5 files changed, 136 insertions(+), 15 deletions(-) diff --git a/frontend/src/components/NavigatorBlock.js b/frontend/src/components/NavigatorBlock.js index f4e3851..d66d35a 100644 --- a/frontend/src/components/NavigatorBlock.js +++ b/frontend/src/components/NavigatorBlock.js @@ -17,7 +17,7 @@ const NavigatorBlock = () => { return ( -

Hardware

+

Navigator

Explanation: JavaScript can be used to find information about diff --git a/frontend/src/components/NewTable.js b/frontend/src/components/NewTable.js index b98fe4e..b7ee48e 100644 --- a/frontend/src/components/NewTable.js +++ b/frontend/src/components/NewTable.js @@ -1,12 +1,14 @@ +import { checkUndefinedProperties } from './navigator'; + const Table = ({ data }) => (

{data.map((item) => ( - + - + ))} diff --git a/frontend/src/components/ScanBlocks.js b/frontend/src/components/ScanBlocks.js index 3fc17e2..9a92af2 100644 --- a/frontend/src/components/ScanBlocks.js +++ b/frontend/src/components/ScanBlocks.js @@ -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 = () => ( <> - + {/* - + */} {/* */} ); diff --git a/frontend/src/components/navigator.js b/frontend/src/components/navigator.js index 590fe5b..c74557c 100644 --- a/frontend/src/components/navigator.js +++ b/frontend/src/components/navigator.js @@ -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; }; diff --git a/frontend/src/styles/App.css b/frontend/src/styles/App.css index d194a2c..2f7b94c 100644 --- a/frontend/src/styles/App.css +++ b/frontend/src/styles/App.css @@ -41,7 +41,7 @@ } .centerBlockInner { - width: 650px; + width: 800px; margin: 24px 0 0 0; }
{item.title} {item.value}{item.test}{checkUndefinedProperties(item)}